Generate passphrase isuue

I got this exception after adding SQLCipher encryption on SQLDelight database " net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;"

Hello @Yosra - that error would indicate that you are using an incorrect key for the database.

so if key wrong then how to get right one if we forget

Hello @Android1500 - there isn’t any way to recover a key if it is lost/forgotten.

Thanks for response so what should i do right now?

Hello @Android1500 - there is not much you can do. If you think you can remember the key, keep the database around. If not, there is no way to recover the database.

Thanks i found my key but i found a issue whenever i use createFromAssert() in roomdb it got crash and in error logs it show android.database.sqlite.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master; i hope you have any solution and for more info i am using pre populated data from createFromAsset.

Hello @Android1500,

I don’t believe the Room API supports interfacing with SQLCipher database files via the createFromAsset(...) function on the builder API. Internally [1], it uses the SQLiteCopyOpenHelperFactory [2], which in turn used the SQLiteCopyOpenHelper [3], which uses a FrameworkSQLiteOpenHelperFactory [4] to test access to the database, this is not aware of SQLCipher.


  1. room/room-runtime/src/main/java/androidx/room/RoomDatabase.kt - platform/frameworks/support - Git at Google ↩︎

  2. room/room-runtime/src/main/java/androidx/room/SQLiteCopyOpenHelperFactory.kt - platform/frameworks/support - Git at Google ↩︎

  3. room/room-runtime/src/main/java/androidx/room/SQLiteCopyOpenHelper.kt - platform/frameworks/support - Git at Google ↩︎

  4. room/room-runtime/src/main/java/androidx/room/SQLiteCopyOpenHelper.kt - platform/frameworks/support - Git at Google ↩︎

why is it not necessary to encrypt/generate-a-secure/random password the passphrase/password?

@Neil_Jay_Warner

We don’t recommend hard coding a passphrase in application code. This post has some additional discussion about SQLCipher Database Key Material and Selection: SQLCipher Database Key Material and Selection