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
attempt to write a readonly database, crashes on android 5.0v devices while using SqlCipher #161
Comments
Hello @praveenb Are you able to replicate the crash on your 5.0 device when running the SQLCipher for Android test suite? |
@developernotes Thank you so much for your kind reply, 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. |
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 |
there is no database file exist before initialize the class... I debugged the android-database-sqlcipher project, by giving external path, as shown below And I see the issue is occurring only when created db file on external storage, Please let me any idea on this. Thankyou |
Hello @praveenb I am wondering if there is an issue within the internals of |
Im getting the same error, invoking SQLiteDatabase.openOrCreateDatabase(…); method Thanks |
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. |
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. |
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. |
Hello @chetan1011 Can you verify whether the database file exists before you attempt to write to it? |
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. |
Hello @developernotes , The database file was store in sdcard(External_storage)... |
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! |
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? |
Hello @developernotes , @developernotes Thank you so much for your kind reply, Yes sir, i check database file is exist or not in sdcard...at that time database is exist in sdcard.. I mean database file is exist in sdcard... still Im getting the same error, android.database.sqlite.SQLiteException: not an error (code 0): Could not open the database in read/write mode. This error got in only 5.0 (lolipop)version in android. Please let me know if you need any other details Thank you. |
FYI the same problem (crash with
@chetan1011 looks like it may be the same problem as #139. |
According to the documentation in http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html, and also in the Javadoc, it is possible that |
Hello brodybits, I am use following code: then i got "attempt to write a read only database" if you hve any solution then please give me your solution ya any sample... please help me dude... |
@chetan1011 can you post the log to show where your application is failing? |
HI @brodybits , 05-29 17:55:20.391: W/System.err(4598): net.sqlcipher.database.SQLiteException: error code 8: attempt to write a readonly database please help me.. |
@chetan1011, for some reason your case is different from the OP. In your case, |
@brodybits dbpath is valid... it's database file and it's exist in sdcard... this code is working fine in all other version but.... it's just not working in 5.0 android version... |
Just issued PR #174 with fixes to show where |
@chetan1011 you may want to hold off on #174 right now, there is still some work going on there. |
…n messages Use throw_sqlite3_exception_errcode() if sqlite3_open_v2() fails Needed to help diagnose exceptions in sqlcipher#139 & sqlcipher#161 Some credit to https://github.com/android/platform_frameworks_base/blob/master/core/jni/android_database_SQLiteConnection.cpp
Just reworked the changes in PR #175 to show where |
Hello @eyeled Thank you for your feedback, we look forward to hearing your results on device. |
Hi,
The Mi 4i device runs Android 5.0.2 Unfortunately in Android 5.0.1 x86_64 emulator following error is displayed -
The same database is working fine in 4.2.2, 5.1.1, 6.0.1 etc. This error appears to be slightly different than what is thrown in Mi 4i phone. But, one thing is sure.. there is some bug that is interfering with SQLCipher to work in Android 5.0.x How I tested - |
Hi! We've encountered the same bug too. atultiwari, thank you very much for finding emulator in which the problem can be easily reproduced. That helped a lot. The error is actually in android headers. For android 19 they have:
but
So ino_t is 4 bytes and stat.st_ino is 8 bytes wide. Sqlite trims inode number to 4 bytes when stores it and then compares with 8 byte wide inode number in fileHasMoved. It seems, that in android 21 headers have been fixed:
So currently I see two solutions: good one is to use headers for android 21. But if that's inappropriate, then the problem can be solved by a hack in sqlite by explicitly converting stat.st_ino to (ino_t) in sqlite source. |
+1 for using the android-21 headers |
@kibergus thank you for finding out the root cause of this issue. Being a medico, it is hard to understand it completely, but I did understand some basics about it. |
I get this issue on my phone, Android 5.0, I see @kibergus's answer, but i don't know how to deal with it,For using the android-21 headers ? How to do it? |
Hi @atultiwari, @YuriZheng, We will look into making the adjustment to the NDK API 21 within the |
Hi @atultiwari, @YuriZheng, We have made some changes in the |
@developernotes thank you for your reply. I will try it in the evening and get back to you. It's 2 a.m. here, feeling very sleepy. But it seems, for |
Hello @atultiwari, Yes, the |
Hello @developernotes : |
@developernotes I too am facing this issue only on 5.0 devices. 05-24 15:46:30.494: I/Database(11744): sqlite returned: error code = 28, msg = file renamed while open: /storage/sdcard0/dummy1/db |
Hello @YuriZheng If you are interested in our |
Hi @developernotes , I am facing this problem using the latest version 3.5.4 on a sony device with android 5.0. net.sqlcipher.database.SQLiteException: error code 8: attempt to write a readonly database. Do you have any suggestions what I could try? |
Are you able to create a small reproducible test case within the SQLCipher for Android test suite? If so, we would be happy to look into that further. Thanks! |
I've added a test case for this. It seems the problem is not really related to the sony device, as I've reproduced it on multiple android versions which have x86_64 system image. It seems there is a problem when using an external storage in this cases. |
Hi Team, We are facing the below issue may be the similar as previous net.sqlcipher.database.SQLiteException: error code 8: attempt to write a readonly database This issue we have only got in MI devices. Please us ASAP. |
Hi Team, We are facing the below issue may be the similar as previous net.sqlcipher.database.SQLiteException: error code 8: attempt to write a readonly database Happens when app having multiple processes. |
@umesh0492 are you saying that the application works if there is only a single process, but fails when there are multiple processes, even if the database location is the same? |
I'm having the same issue, also seems to be related to multi-processes application. Any update on this? |
Hi @ArikYa What version of SQLCipher for Android are you currently using? |
I use it through Requery, which uses 3.5.4 |
Hello @ArikYa Please try the latest version of SQLCipher for Android, which is 3.5.7 and let us know your results. Thanks! |
Hello guys, I'm facing the same issue. I'm using the latest version 3.5.7 now.
|
Struggling several hours then I found the issue is the database path. |
Hi @dotw We are glad to hear you were able to resolve the issue. Thanks! |
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.
The text was updated successfully, but these errors were encountered: