Skip to content

PRAGMA cipher_migrate fails with openDatabase #115

Closed
@MufriA

Description

@MufriA

With latest 3.0.1 release, openDatabase fails to migrate whereas openOrCreateDatabase have no issues.

Failure is at setLocale with encrypted or corrupted file error message.

//no issues
db = SQLiteDatabase.openOrCreateDatabase(path, password, null, hook);

//always fails
db = SQLiteDatabase.openDatabase(path, password, null, SQLiteDatabase.OPEN_READWRITE, hook);

MigrateDatabaseHook hook = new AlwaysMigrateDatabaseHook(password);

public static class MigrateDatabaseHook implements SQLiteDatabaseHook {

        private String mPassword;
        MigrateDatabaseHook(String password) {
            mPassword = password;
        }

        @Override
        public void preKey(final SQLiteDatabase sqLiteDatabase) {
            sqLiteDatabase.execSQL(String.format("PRAGMA key = '%s'", mPassword));
            android.database.Cursor c = sqLiteDatabase.rawQuery("PRAGMA cipher_migrate", null);
            tryCloseCursor(c);
        }

        @Override
        public void postKey(final SQLiteDatabase sqLiteDatabase) {
        }
}            

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions