Integrating SQLCipher with greenDAO
Asked Answered
A

1

1

How to encrypt sqlite database in android with sqlchipher while using greenDao orm. I have searched this many time in SO , but didn't find any working solution .

Astrict answered 22/9, 2016 at 11:17 Comment(0)
A
1

In your greendao generator module add this dependency

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

So the build.gradle file your generator module will look like this

apply plugin: 'java'

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

}

And the in your app gradle file (build.gradle module app) add these dependencies and remove all other greendao related dependencies

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

and set up database like this way

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

If there is any other option to do this , please share

Astrict answered 22/9, 2016 at 11:17 Comment(1)
i'm trying to read the data from daoSession but have 0 records.Sausa

© 2022 - 2024 — McMap. All rights reserved.