fahad_sust
fahad_sust

Reputation: 546

After updating SqlCipher version to 4.2.0 version I get a crash

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

Upvotes: 0

Views: 420

Answers (1)

fahad_sust
fahad_sust

Reputation: 546

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) {

            }
        });

Upvotes: 0

Related Questions