Hi,
I have an existing Android App with encrypted DB (encrypted using SQL cipher 2.2.0)
Recently we updated the cipher lib to 3.3.1-2 ( compile ‘net.zetetic:android-database-sqlcipher:3.3.1-2@aar’)
App works fine on new installation. Problem occurs on devices where i am trying to use existing set up (i mean access existing Db)
Following is my code.
SQLiteDatabaseHook hook=new SQLiteDatabaseHook() {
public void preKey( SQLiteDatabase database){
database.rawExecSQL("PRAGMA cipher_default_use_hmac=off;");
}
public void postKey( SQLiteDatabase database){ }
};
try {
SQLiteDatabase source=SQLiteDatabase.openOrCreateDatabase(databaseToMigrate,password,null,hook);} catch(Exception e) { }
********DB was created using this line *************
db = SQLiteDatabase.openOrCreateDatabase(vDbPath, mdbEKey, null);
It gives following error:
11-17 14:02:24.067 2247-2247/org.bz.mws.Screens I/Database: sqlite returned: error code = 26, msg = file is encrypted or is not a database
11-17 14:02:24.067 2247-2247/org.bz.mws.Screens E/Database: CREATE TABLE android_metadata failed
11-17 14:02:24.069 2247-2247/org.bz.mws.Screens E/Database: Failed to setLocale() when constructing, closing the database
11-17 14:02:24.069 2247-2247/org.bz.mws.Screens E/Database: net.sqlcipher.database.SQLiteException: file is encrypted or is not a database: create locale table failed
I am stuck in this for quiete a few days. please help to resolve this. Tried out different options in PreKey but nothing helped.
Thanks in advance.