How to read encrypted database created earlier on computer with sqlcipher on Android?
I am trying to read an encrypted database created with sqlcipher on my PC, but I cannot read it in my application. For example:
Cursor c = database.rawQuery("SELECT name FROM sqlite_master WHERE type='table'", null);
c.moveToFirst();
do {
String s = c.getString(0);
if (s.equals("android_metadata")) {
// System.out.println("Get Metadata");
continue;
} else {
dirArray.add(s);
}
} while (c.moveToNext());
Log.i("getS", "DATABASE = " + dirArray.toString());
Log.i("getS", "length = " + dirArray.size());
will lead to the following
03-12 03:28:12.691: I/getS(9895): DATABASE = []
03-12 03:28:12.691: I/getS(9895): length = 0
also:
Cursor c2 = database.query("my_table", new String[] { "name" }, null, null, null, null, "name");
come back here:
03-12 03:28:12.701: I/Database(9895): sqlite returned: error code = 1, msg = no such table: my_table
I compile with sdk-7, if I try to use the same database without encryption and without sqlcipher, I have no problem. Can anyone teach me how can I read a database encrypted on my computer on an Android server? Appreciate;)
+3
source to share
1 answer
You will want to use the Android SQLCipher library which will allow you to access and modify the sqlcipher database on an Android device. We currently support Android 2.1 - 4.0.3. Binary downloads can be found here:
https://github.com/sqlcipher/android-database-sqlcipher/downloads
A tutorial on itegrating SQLCipher for Android can be found here:
+1
source to share