Hi @FrozenPyrozen,
Thank you for providing an update on your goals. Since your aim is to maintain compatibility with version 3 database file formats, you can provide the following hook when you open your connection:
SQLiteDatabaseHook hook = new SQLiteDatabaseHook() {
public void preKey(SQLiteDatabase database) {}
public void postKey(SQLiteDatabase database) {
database.execSQL("PRAGMA cipher_compatibility = 3;");
}
};
If you are getting an error where it fails to open the database (and you can reproduce this locally), it would be best to pull that database off the device/emulator and attempt to access the database file using the SQLCipher shell, or graphical management interface such as DB Browser for SQLite. Would you give that a try and let us know your result?
1 Like
Hi, @developernotes
Iâve get db from emulator after we updated newer build with android 14 changes and cipher version, but looks like it didnât opened, maybe smth wrong with password
Iâve added some logging code to see db info, so my postKey
code looks like this, not sure what encryption settings should I use
@FrozenPyrozen why donât you try using the âSQLCipher 3 Defaultsâ setting in DB Browser for SQLite?
Hi, @sjlombardo Itâs doesnât work, maybe password encypted or wrong
Hi @developernotes, could you verify that db file needs to be in format NameDB
without any type extension like NameDB.sql
?
@FrozenPyrozen there are no restrictions on database file names. They can have extensions or not, SQLCipher does not care.
You need to remove all this from your postKey
:
database.execSQL("PRAGMA kdf_iter = 256000;");
database.execSQL("PRAGMA cipher_hmac_algorithm = HMAC_SHA512;");
database.execSQL("PRAGMA cipher_kdf_algorithm = PBKDF2_HMAC_SHA512;");
database.execSQL("PRAGMA cipher_page_size = 4096;");
Those setting are overriding the backwards compatibility settings you made previously with database.execSQL("PRAGMA cipher_compatibility = 3;");
.