Description
Im getting following log on app crash, on android 5.0v devices
Caused by: net.sqlcipher.database.SQLiteException: attempt to write a readonly database
at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2096)
at net.sqlcipher.database.SQLiteDatabase.(SQLiteDatabase.java:1962)
at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:881)
at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:913)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:132)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:99)
at PackageName.DBHelperCipher.(DBHelperCipher.java:93)
at PackageName.ProcessDBCipherInitTask.doInBackground(ProcessDBCipherInitTask.java:20)
at PackageName.ProcessDBCipherInitTask.doInBackground(ProcessDBCipherInitTask.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
I've submitted a question on StackOverflow, http://stackoverflow.com/q/29988933/341443.
Can you please help on this.
Thank you.
Activity
developernotes commentedon May 4, 2015
Hello @praveenb
Are you able to replicate the crash on your 5.0 device when running the SQLCipher for Android test suite?
praveenb commentedon May 5, 2015
@developernotes Thank you so much for your kind reply,
I run the test suite on Android 5.0 device, Though I see a crash at some other test condition, I do not see a crash resulting error log given above. i.e I'm not able to replicate above crash.
Not sure where im doing mistake in my code. I think i need to investigate further in test suite to handle the issue in my project.
But, I just like to ask,.. you have any other suggestions or guidelines for me on this.
Thank you.
developernotes commentedon May 5, 2015
Hello @praveenb
Do you have a specific test case that is failing consistently in the test suite?
With regard to your specific scenario though, does the database file exist right before you initialize the
DBHelperCipher
instance?praveenb commentedon May 8, 2015
@developernotes,
there is no database file exist before initialize the class...
Just for clarification, I published app to Play Store, I see app crashes, When I do a fresh install from play store, on a android 5.0v device.
I debugged the android-database-sqlcipher project, by giving external path, as shown below
public EventDataSQLHelper(Context context, String name, CursorFactory factory, int version) {
super(context, DB_PATH+DATABASE_NAME, null, DATABASE_VERSION);
}
**here DB_PATH constant refers to external path.
And I see the issue is occurring only when created db file on external storage,
see the issue occurring at this line
setLocale(Locale.getDefault()); in SQLiteDatabase file
Please let me any idea on this.
Thankyou
developernotes commentedon May 8, 2015
Hello @praveenb
I am wondering if there is an issue within the internals of
getWritableDatabase()
. As an experiment, could you try invokingSQLiteDatabase.openOrCreateDatabase(…);
before you initialize yourEventDataSQLHelper
only when the database file does not exist before hand? Could you let us know your results? Thanks!praveenb commentedon May 12, 2015
Im getting the same error, invoking SQLiteDatabase.openOrCreateDatabase(…); method
Thanks
developernotes commentedon May 12, 2015
Hello @praveenb
If you can prepare a test within the test suite, I would be glad to take a look at it on a Lollipop device.
praveenb commentedon May 13, 2015
Hi @developernotes ,
Please see this link https://github.com/praveenb/sqlcipher-android-tests, I added test class to test suite. Please see committed code changes.
Hi Nick, You are able to see issue on your side. or You see any issue in committed changes. Please reply on this.
FYI, I see this issue on Lenovo A7000, Lollipop device. Please help on this.
Thank you.
chetan1011 commentedon May 27, 2015
Hi @developernotes ,
I am getting the same error,error code 8: attempt to write a read only database
When I am write(Insert) record in database at this time I am getting this error in my lolipop device.
please help me ...
FYI, I see this issue on Lenovo A7000-a, Lollipop device. Please help on this.
developernotes commentedon May 27, 2015
Hello @chetan1011
Can you verify whether the database file exists before you attempt to write to it?
praveenb commentedon May 28, 2015
Hi @developernotes ,
You are able to look at the test suit changes that i made at this link https://github.com/praveenb/sqlcipher-android-tests.
Please let me know if you need any other details
Thank you.
chetan1011 commentedon May 28, 2015
Hello @developernotes ,
The database file was store in sdcard(External_storage)...
and i take permission in android manifest "android.permission.WRITE_EXTERNAL_STORAGE"
developernotes commentedon May 28, 2015
Hello @chetan1011
Can you verify whether the database file exists on the SD card prior to any attempts to interact with it via the SQLCipher API? Thanks!
BenPope commentedon May 28, 2015
I'm having a similar problem on Android 5.0.2 with native (c++) sqlcipher 3.3.0.
I get an exception "attempt to write a readonly database".
It's weird. The app manages to write the database on startup.
It also fails miserably if I try to put it into EXCLUSIVE locking mode, could it somehow be trying to lock the file more than once?
65 remaining items