Skip to content

Database directory not lazy-created #56

Closed
@commonsguy

Description

@commonsguy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions