3

I'm trying to read an encrypted database created with sqlcipher on my PC but I can't read it on my app. 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());

result on the following

03-12 03:28:12.691: I/getS(9895): DATABASE = []
03-12 03:28:12.691: I/getS(9895): length = 0

also this:

Cursor c2 = database.query("my_table", new String[] { "name" }, null, null, null, null, "name");

return in to this:

03-12 03:28:12.701: I/Database(9895): sqlite returned: error code = 1, msg = no such table: my_table

I'm compiling with sdk-7, if I try the same database unencrypted and without the sqlcipher, I don't have any problems. Could anyone teach me how do I read on android a database encrypted on my computer? Appreciate ;)

aanm
  • 41
  • 4
  • I ran into a similar issue and received a solution: http://stackoverflow.com/questions/9742686/sqlcipher-sharing-a-windows-created-database-with-an-android-application – Blue Dusk Mar 20 '12 at 13:49
  • @djx- were you able to solve the problem ?? i would really apprecaite any help ! thanks – nia Nov 18 '12 at 19:37

1 Answers1

1

You will want to use the SQLCipher for Android library which will allow you to access and modify a 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:

http://sqlcipher.net/sqlcipher-for-android/

Nick Parker
  • 1,378
  • 1
  • 7
  • 10
  • I already add the libraries like it's on tutorial, but still doesn't work. – aanm Mar 13 '12 at 14:01
  • 1
    Also, that tutorial doesn't teach how to read a database created from PC – aanm Mar 13 '12 at 20:30
  • 1
    @djx- were you able to solve the problem ?? i would really apprecaite any help ! thanks – nia Nov 18 '12 at 19:37
  • @nia - Sorry but no, since then I was waiting if anyone had any example or something like that. If you get any progress please tell me. – aanm Nov 19 '12 at 02:19
  • @aanm I'm facing it now too... Did you solve the probem? I'm stuck and unable to get any help... – Virthuss Oct 14 '15 at 07:25