Issue Migrating android-database-sqlcipher:4.5.3 to android-database-sqlcipher:4.7.0

Hello, I’m working in an app that were using android-database-sqlcipher:4.5.3. After update to android-database-sqlcipher:4.7.0 The app is not able to read the data base created by 4.5.3.
The log show this error : net.zetetic.database.sqlcipher.SQLiteNotADatabaseException: file is not a database (code 26): , while compiling: PRAGMA journal_mode.
Regards.

Hi @javiergonzalezb,

Have you tried pulling the database file off device and attempt to open it with the SQLCipher command line tool? This would be a good isolation test as it will confirm the password material is correct and the cause would likely be due to some behavior within the application itself.

With the SQLCipher 4.7.0 release [1], an upstream change to the SQLite project was made which requires the applications to set the key prior to executing any SELECT-type SQL statements as they do read the database file, subsequently triggering key derivation.

This could also be caused if you have an existing WAL file present at startup, this could occur if the application crashed during a previous execution. In this situation, your application could be attempting to perform a recovery of the WAL file which would cause the database file to be read and trigger key derivation. We would suggest you review your application, and make sure you are always supplying the password material prior to executing any SQL commands.

You can also use the profiler [2] to gain visibility into what queries may be running and their order.


  1. SQLCipher 4.7.0 Release | Zetetic ↩︎

  2. SQLCipher API - Full Database Encryption PRAGMAs, Functions, and Settings | Zetetic ↩︎