Created
December 20, 2016 00:40
-
-
Save zodani/274622cdce9d0fc85edf2e620e2315ed to your computer and use it in GitHub Desktop.
SQLCipher decrypt
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
public void decrypt() { | |
if(db.isOpen()) { | |
File unencFile = mContext.getDatabasePath("decrypted.db"); | |
if(!unencFile.exists()) { | |
db.rawExecSQL(String.format("ATTACH DATABASE '%s' as plaintext KEY '';", unencFile.getAbsolutePath())); | |
db.rawExecSQL("SELECT sqlcipher_export('plaintext');"); | |
db.rawExecSQL("DETACH DATABASE plaintext;"); | |
SQLiteDatabase sqlDB = SQLiteDatabase.openOrCreateDatabase(unencFile, null); | |
sqlDB.close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment