SQLCipher - Sharing Windows Database with Android Application

I compiled the SQLCipher version of the sqlite3 command line shell on Windows and successfully created an encrypted database. Then I wanted to see if I can use this database in an Android application. I copied the database to my Android app and tried to call SQLiteDatabase.openDatabase and passed the key I used on Windows, but I got this:

"Caused by: info.guardianproject.database.sqlcipher.SQLiteException: file is encrypted or not database

Has anyone tried to create an encrypted database on Windows first and then package that database with their application? If so, what's the process for entering and opening a database in an android app?

I read the links below but didn't find a solution:


How to read an encrypted database created earlier on a computer with sqlcipher on Android?


source to share

1 answer

If you are using the SQLCipher 2 command line tool to create a database, you must:

  • Use SQLCipher for Android 2.0.0 (https://github.com/sqlcipher/android-database-sqlcipher/downloads); or
  • When creating a database using the command line, run PRAGMA cipher_use_hmac = OFF immediately after setting the key for the new database to disable HMAC. This will create a 1.1.x compatible database that will work with SQLCipher for Andodi 1.x


All Articles