GreenDAO with Sqlcipher Integration Example

2019-04-21 23:51发布

问题:

I have setup a new project using GreenDAO, was able to generate with ExampleDAO using DaoGenerator. Everything works fine.

I also have a prepopulated sqlite database shipped in android assets folder, on app run, it is being copied to android database system path.

Now I want to integrate with SqlCipher, to have my database encrypted... If anybody can help or give example app, that would be a great help.

回答1:

Please let me know if these solutions work for you:

A sample project with the integration: https://github.com/ywenblocker/GreenDao-SQLCipher

Here is the original thread with all discussion about how to implement it: https://github.com/greenrobot/greenDAO/issues/6

Edit:

After removing the private libraries from the build path, and adding them again, I found a not implemented method of DevOpenHelper:

sDaoMaster = new DaoMaster(sDevOpenHelper.getWritableDatabase("secret-key"));

There was no such method implemented on the sample project, unfortunately it looks like you should implement the getWritable and getReadable methods all by yourself. Without these modifications you would get a non-encrypted database, as shown by screenshoots below:

Device ScreenShot:

Database snapshot: