Skip to content

Instantly share code, notes, and snippets.

@kmusham
Created January 10, 2014 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmusham/8214418bdd71ef6e5de3 to your computer and use it in GitHub Desktop.
Save kmusham/8214418bdd71ef6e5de3 to your computer and use it in GitHub Desktop.
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();
}
}
@susanSanjhya
Copy link

where should i call this method??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment