Description
Environment: SQLCipher for Android 2.0.5, as tested on Android 2.2 and 4.0.3 ARM emulators.
Scenario: Install an app, so there is no database directory for the app. Attempt to open a readable database using SQLiteOpenHelper
. You crash with:
sqlite3_open_v2("/data/data/com.commonsware.sct/databases/constants.db", &handle, 6, NULL) failed
Or, if you create the directory (e.g., context.getDatabasePath(DATABASE_NAME).getParentFile().mkdirs();
), and you attempt to open a readable database, you crash with:
E/AndroidRuntime(1293): Caused by: net.sqlcipher.database.SQLiteException: Can't upgrade read-only database from version 0 to 1: /data/data/com.commonsware.sct/databases/constants.db
Workaround: Don't open a readable database unless the database already exists. Open a writable database instead.
What Should Happen: The database directory should be lazy-created and a database created, even if you said you only needed a readable database.
Sample Code: http://misc.commonsware.com/SQLCipherTest.zip