1

I encrypted my already existing sqlite database using following method given on sqlcipher documentation

$ ./sqlite3 plaintext.db 
sqlite> ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'testkey'; 
sqlite> SELECT sqlcipher_export('encrypted'); 
sqlite> DETACH DATABASE encrypted;

this works and produces an encrypted database with comparable memory size like original. and then I tried to access the database on my android application using

SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(myDatabasePath, "testkey", null);

querying on db instance shows that there are no existing tables in the database. I am able to create new tables as well as add rows to them and read them but I can't see my old existing tables. I carefully followed the guidelines given in the sqlcipher documentation of changing imports.

Rohit
  • 1,878
  • 19
  • 26
  • 1
    Are you absolutely certain that you are accessing the right database *file*? Remember that `openOrCreateDatabase()` will create an empty database if you try accessing one by name that does not already exist. – CommonsWare Nov 18 '12 at 18:26
  • yup, this time I ran the app on emulator and pulled the created database and it was the same database. – Rohit Nov 18 '12 at 19:07
  • decrypted the pulled database. found to contain one extra table which I created later while using the app + the originally existing tables but the same app is not able to access these other tables while running. weird – Rohit Nov 18 '12 at 19:17
  • Are you bundling the exported database in the assets directory of your application? – Nick Parker Nov 19 '12 at 14:07
  • Hi, ya I have the exported database as zipped file in assets directory. – Rohit Nov 19 '12 at 14:15

0 Answers0