且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从android sqlcipher移动到android sqlite数据库

更新时间:2023-11-25 15:45:10

正在将您的SQLCipher库升级到最新版本,目前为3.1.0,而您之前的版本为2.x(正如上述注释中所述),您还需要升级数据库文件格式。 3.x版本发生的重大变化之一是将关键推算长度从4,000增加到了64,000。如果使用所有标准的SQLCipher配置,则升级数据库格式是直接的。我们已经包括一个新的PRAGMA调用 cipher_migrate ,将为您执行此操作。您可以在 SQLiteDatabaseHook postKey 事件中执行此操作,该事件将在您的呼叫中提供 SQLiteDatabase.openOrCreateDatabase 。一个例子可以在Android测试套件的SQLCipher中找到 here

If you are upgrading your SQLCipher library to the latest version, currently at 3.1.0, and your previous version was 2.x (as you mentioned in the comments above), you will need to upgrade the database file format as well. One of the big changes in the 3.x release was an increase in key derivation length, from 4,000 to 64,000. If you are using all of the standard SQLCipher configurations, upgrading the database format is straight forward. We have included a new PRAGMA call cipher_migrate that will perform this operation for you. You can execute this within the postKey event of the SQLiteDatabaseHook which is to be provided in your call to SQLiteDatabase.openOrCreateDatabase. An example of this can be found in the SQLCipher for Android test suite here.