Could not open database file. Reason: file is not a database

0

I wrote the code to migrate the db from 3.x to 4.2 in my Android app, and I have upgraded my DB Browser for SQLite Windows app.

I can open the file in the app. However, after downloading the db file from Device Explorer, I can no longer open the db file in DB Browser.

Could not open database file. Reason: file is not a database

What am I doing wrong?

private static void migrate(String passKey) {
    final boolean[] status = {false};
    try {
        SQLiteDatabaseHook hook = new SQLiteDatabaseHook() {
            public void preKey(SQLiteDatabase database) {
            }
            public void postKey(SQLiteDatabase database) {
                String value = QueryHelper.singleValueFromQuery(database, "PRAGMA cipher_migrate");
                status[0] = Integer.parseInt(value) == 0;
            }
        };
        SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(MyApp.dbFile,
                passKey, null, hook);
        database.close();
    } catch (Exception e) {
        Log.i(TAG, "error", e);
    }
}

Hi @LiveSmart

Are you referring to your application, or DB Browser for SQLite? If you are referring to DB Browser for SQLite, which version are you referring to? The nightly edition allows for accessing both SQLCipher 3 and SQLCipher 4 series database formats.

As a general thought, Android itself seems to have occasional problems copying SQLite/SQLCipher files from a device to a computer.

No idea why, but it’s something we occasionally get user reports about (with the DB Browser for SQLite project). And it always turns out the copying process has incorrectly copied the database file.

My best guess is to reboot the Android device, try copying the database file over again, and hope for the best. :smile: