-
-
Save kmusham/8214418bdd71ef6e5de3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void migrateSqlCipher(File dbFile) { | |
SQLiteDatabaseHook hook = new SQLiteDatabaseHook() { | |
public void preKey(SQLiteDatabase database) { | |
} | |
public void postKey(SQLiteDatabase database) { | |
Cursor cursor = null; | |
try { | |
System.out.println("migrating sqlcipher start"); | |
cursor = database.rawQuery("PRAGMA cipher_migrate;", | |
new String[] {}); | |
if (cursor != null) { | |
cursor.moveToFirst(); | |
System.out.println("migrate pragma query result getStrint(0) = "+ | |
cursor.getString(0)); | |
} | |
System.out.println("migrating sqlcipher end"); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} finally { | |
if (cursor != null) { | |
cursor.close(); | |
cursor = null; | |
} | |
} | |
} | |
}; | |
SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(dbFile, | |
DbDef.DB_PWD, null, hook); | |
if (database != null) { | |
database.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where should i call this method??