【问题标题】:Integrating SQLCipher with greenDAO将 SQLCipher 与 greenDAO 集成
【发布时间】:2016-09-22 11:17:17
【问题描述】:

如何在使用greenDao orm时使用sqlchipher加密android中的sqlite数据库。我在 SO 中搜索了很多次,但没有找到任何可行的解决方案。

【问题讨论】:

    标签: android encryption android-sqlite greendao sqlcipher


    【解决方案1】:

    在你的greendao生成器模块中添加这个依赖

    compile 'org.greenrobot:greendao-generator-encryption:2.2.0'
    

    所以你的生成器模块的 build.gradle 文件看起来像这样

    apply plugin: 'java'
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'org.greenrobot:greendao-generator-encryption:2.2.0'
    
    }
    

    并且在你的应用程序 gradle 文件(build.gradle 模块应用程序)中添加这些依赖项并删除所有其他与 greendao 相关的依赖项

    compile 'org.greenrobot:greendao-encryption:2.2.2'
    compile 'net.zetetic:android-database-sqlcipher:3.5.1'
    

    这样设置数据库

      DaoMaster.EncryptedDevOpenHelper helper = new DaoMaster.EncryptedDevOpenHelper(context, "secrets.db");
      Database database = helper.getWritableDatabase("your secret key");
      DaoMaster daoMaster = new DaoMaster(database);
    

    如果有其他选择,请分享

    【讨论】:

    • 我正在尝试从 daoSession 读取数据但有 0 条记录。
    猜你喜欢
    • 2014-04-07
    • 2012-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-26
    • 2015-11-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多