0

After updating to SqlCipher version to 4.2.0, I am getting a crash with below backtrace though it was working in previous version 3.5.9.

net.sqlcipher.database.SQLiteException: file is not a database
fahad_sust
  • 526
  • 1
  • 6
  • 21

1 Answers1

0

It was creating the problem for new database file formate[Note: SqlCipher update and change it's database file format in new version for ensuring more security]. For that reason it can not find the Database in db location and got that crash. Simply migrating the database solved the problem. Sample code for migration is given below:

        super(context, DB_NAME, null, DB_VERSION, new SQLiteDatabaseHook() {
            @Override
            public void postKey(SQLiteDatabase database) {
                database.rawQuery("PRAGMA cipher_migrate", null).close();
            }

            @Override
            public void preKey(SQLiteDatabase database) {

            }
        });
fahad_sust
  • 526
  • 1
  • 6
  • 21