Closed sunilsunny565 closed 1 year ago
I'm just answering my own question I had to pass SQLiteDatabaseHook
and that resolved the issue
val hook: SQLiteDatabaseHook = object : SQLiteDatabaseHook {
override fun preKey(database: SQLiteDatabase) {
// do nothing
}
override fun postKey(database: SQLiteDatabase?) {
database?.rawExecSQL(POST_KEY_SQL_MIGRATE)
}
}
val factory = SupportFactory(SQLiteDatabase.getBytes(dbKey), hook)
dbBuilder.openHelperFactory(factory)
}
const val POST_KEY_SQL_MIGRATE = "PRAGMA cipher_migrate;"
it might be a good idea if this can be mentioned in the wiki I guess.
Hi @sunilsunny565
We are happy to hear that you were able to solve the issue. The SQLiteDatabaseHook
usage with SupportFactory
is covered within the README here. If you have any other questions, please consider posted to the SQLCipher Community Discuss site as we tend to only track software defects within GitHub Issues. Thanks!
I'm trying migrate from using https://github.com/commonsguy/cwac-saferoom to SQLCipher library as Saferoom is no more maintained. I didn't had any issues with SafeRoom I was using
"com.commonsware.cwac:saferoom:1.2.1"
which is using SQLCipher version4.2.0
and this is how I'm using it.Where
dbBuilder
is justRoom.databaseBuilder
Now to to update to
SQLCipher :4.5.2
replaced above code withAnd after this change I started to get this error
file is not a database: , while compiling: select count(*) from sqlite_master;
which I feel happens when the dbKey is different, but in this case I haven't changed the key. Am I missing something in this migration? @commonsguy , can you please help?.