GreenDAO与Sqlcipher集成示例 [英] GreenDAO with Sqlcipher Integration Example

查看:987
本文介绍了GreenDAO与Sqlcipher集成示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装使用GreenDAO一个新的项目,能产生与使用DaoGenerator ExampleDAO。一切工作正常。

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

我也有一个prepopulated SQLite数据库出货的Andr​​oid资产的文件夹中,对应用程序来说,它被复制到Android数据库系统的路径。

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

现在我要与SqlCipher整合,有我的数据库加密......如果有人能帮助或给示例应用程序,这将是一个很大的帮助。

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.

推荐答案

请让我知道如果这些解决方案为你工作:

Please let me know if these solutions work for you:

与整合的样本项目: https://github.com/ywenblocker/GreenDao-SQLCipher

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

下面是有关如何实现这一切的讨论原来的线程: https://github.com/greenrobot/greenDAO/issues/6

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

编辑:

从构建路径除去私人图书馆,并再次将其添加后,我发现DevOpenHelper的未实现的方法:

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"));

有对样本项目实施这样的方法,不幸的是它看起来像你应该实现getWritable和getReadable方法,全部由自己。没有进行这些修改就会得到一个非加密数据库,如由下面screenshoots:

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:

设备截图:

数据库快照:

这篇关于GreenDAO与Sqlcipher集成示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆