Hi @developernotes! ![]()
I’ll try to explain the issue in detail. The migration seems fine, and everything works correctly when I update from an older version using SQLCipher 3.5.9 to the latest version 4.6.1 (on a non 16kb emulator). The problem arises in a specific scenario:
- On a 16 KB device, with a clean install (with or without the hook), everything works as expected.
- However, when updating from an older version, the app crashes when trying to create the database using the following code:
SQLiteDatabase.openOrCreateDatabase(databaseFile.getAbsolutePath(), getKey(), null, null, hook);
The crash happens within the SQLCipher code, throwing the following exception:
android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5): , while compiling: SELECT COUNT(*) FROM sqlite_schema;
the hook class:
class MyDatabaseHook : SQLiteDatabaseHook {
override fun preKey(connection: SQLiteConnection?) {}
override fun postKey(connection: SQLiteConnection?) {
connection?.executeRaw("PRAGMA cipher_migrate", null, null)
}
}
I have tried many ways in all possible combinations, also with the executeForLong like you suggested,
this issue does not occur on non-16 KB devices or emulators, where the migration works as expected.
if try a clean install without migration from sqlchiper 3, it also works fine, on both 16kb and non 16kb emulators,
Any guidance or suggestions would be greatly appreciated!