Android 上的 Sqlite 文件加密或不是数据库
我有一个在 Android 上使用 sqlite 的应用程序。一切正常,我可以毫无问题地创建、读取和写入数据库。 但是如果我更改 eclipse 中的源代码(只要重新编译就没关系),则会创建新的 apk 并将其推送到模拟器。现在访问数据库将导致
在此处输入代码03-07 15:50:03.886: ERROR/AndroidRuntime(311): Caused by: android.database.sqlite.SQLiteException: file is generated or is not a database
使用文件资源管理器删除数据库文件并访问数据库,将重新创建数据库,一切都会恢复正常。
我确信每次访问后数据库都会关闭。
I've got an app using sqlite on android. Everything works fine, I can create, read and write the database without any problems.
BUT if I change the sourcecode in eclipse (doesn't matter what as long as it recompiles) the new apk is created and pushed to the emulator. Accessing the database now will result in
enter code here03-07 15:50:03.886: ERROR/AndroidRuntime(311): Caused by: android.database.sqlite.SQLiteException: file is encrypted or is not a database
Deleting the database file with the file explorer and accessing the database, will recreate the db and everything is fine again.
I'm sure the db is closed after every access.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也发现这个错误了!最后,我决定从我的应用程序创建数据库文件,执行一些代码,例如:
下一步是将此文件从 DDMS 视图导出到文件并使用 SQLite 管理器打开该文件。在这里您可以导入所有数据和其他表格。
最后一步只需从 SQLiteManager 导出此数据库,如果打开此文件,您可以看到它已加密。
我知道这是一个暂时的解决方案,但它可以解决这个问题,而且你只需要这样做一次,不再需要。
祝你好运!
I've found this error too! And Finally I've decided to create the DB file from my APP, executing some code like:
Next step is export this file from DDMS view to file and open that file with SQLite manager. Here you will can to import all your datas and another tables.
Final step only need to export this database from SQLiteManager and if you open this file you can see it is encrypted.
I know this is a temporal solution but It can solve this problem, and you only need to do this one time and no more.
Good luck!