Skip to content

Database directory not lazy-created #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
commonsguy opened this issue May 29, 2012 · 1 comment
Closed

Database directory not lazy-created #56

commonsguy opened this issue May 29, 2012 · 1 comment

Comments

@commonsguy
Copy link
Collaborator

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

@developernotes
Copy link
Member

Hi commonsguy,

Thanks for the report, I've merged in a fix into master to address this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants