Issue Migrating From android-database-sqlcipher:3.5.9 to sqlcipher-android:4.5.5

Hello
I am migrating from net.zetetic:android-database-sqlcipher:3.5.9 to net.zetetic:sqlcipher-android:4.5.5

My implementation looks like below.

private DatabaseHelper(Context context) {
super(context, DBNAME, null, VERSION);
this.context = context;
}

@Override
public void onCreate(SQLiteDatabase db) {
	db.execSQL(CREATE_PERFORMANCE);
	db.execSQL(CREATE_TICKET);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	Log.w(Constants.tag, "Upgrading database from version " + oldVersion + " to " + newVersion
			+ ", which will destroy all old data");
	db.execSQL("DROP TABLE IF EXISTS ticket"); //
	db.execSQL("DROP TABLE IF EXISTS performance"); //
	onCreate(db);
}

public DatabaseHelper open() throws SQLException {
	System.loadLibrary("sqlcipher");
	database = this.getWritableDatabase();
	return this;
}

public SQLiteDatabase getDatabase() {
	if(database == null){
		System.loadLibrary("sqlcipher");
		database = getWritableDatabase();
	}
	return database;
}

I made changes after referring SQLCipher for Android Migration - How to Convert Applications from android-database-sqlcipher to sqlcipher-android | Zetetic

but when getWritableDatabase() gets called , crashing with below message
Caused by: android.database.sqlite.SQLiteException: file is not a database (code 26): , while compiling: PRAGMA journal_mode

please help on this, I am stuck since few days.

Hi @Anshuman_Biswal

Thank you for your interest in SQLCipher and for posting to the discussion forum.

SQLCipher 3.x has different encryption settings than SQLCipher 4.x, so you’ll need to migrate your database(s) to use these new encryption settings (or open them in compatibility mode) as outlined in this post: Upgrading to SQLCipher 4

SQLCipher should properly migrate all your tables and database data when performing the migration, so you shouldn’t need to drop your tables and re-create them onUpgrade like you’re doing unless that’s an application requirement.