Skip to content

unable open db from sdcard #88

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
algoroq opened this issue Feb 3, 2013 · 3 comments
Closed

unable open db from sdcard #88

algoroq opened this issue Feb 3, 2013 · 3 comments

Comments

@algoroq
Copy link

algoroq commented Feb 3, 2013

I can't open encrypted db from sdcard.

The code

database = SQLiteDatabase.openDatabase(filePath, password, null, SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS);

or

database = SQLiteDatabase.openDatabase(filePath, password, null, SQLiteDatabase.OPEN_READWRITE| SQLiteDatabase.NO_LOCALIZED_COLLATORS);

throws the same exception

02-03 17:40:15.815: I/Database(3470): sqlite returned: error code = 8, msg = statement aborts at 4: [DELETE FROM android_metadata] attempt to write a readonly database
02-03 17:40:15.815: E/Database(3470): DELETE failed setting locale
02-03 17:40:15.830: E/Database(3470): Failed to setLocale() when constructing, closing the database
02-03 17:40:15.830: E/Database(3470): net.sqlcipher.database.SQLiteException: attempt to write a readonly database
02-03 17:40:15.830: E/Database(3470):   at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
02-03 17:40:15.830: E/Database(3470):   at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2101)
02-03 17:40:15.830: E/Database(3470):   at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1967)
02-03 17:40:15.830: E/Database(3470):   at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:900)
02-03 17:40:15.830: E/Database(3470):   at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:947)

I also tried add and remove android_metadata table unfortunately without success.

@developernotes
Copy link
Member

Hi algoroq,

Did you include the the icudt46l.zip file in your deployment within the assets directory?

@otiasj
Copy link

otiasj commented Oct 2, 2014

I have the same problem,
I think there is a bug in sqlcipher/.../SQLiteDatabase.java

around line 950 : the 2 openDatabase methods are overriding the flags with CREATE_IF_NECESSARY
openDatabase(String path, String password, CursorFactory factory, int flags)

@developernotes
Copy link
Member

Helo @otiasj

We will look into this further. Thanks!

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

3 participants