Android APP OCCURS "attempt to write a readonly database"

03-10 02:07:56.401: I/Database(19803): sqlite returned: error code = 1032, msg = statement aborts at 60: [UPDATE friends SET third_uflag=?, second_uflag=?, first_uflag=?]
03-10 02:07:56.401: D/BaiduHi(19839): Thread-3389:HiCore [OFFLINE]: handleWriteDone, wirte 72 bytes, total=23615
03-10 02:07:56.401: E/Database(19803): Error updating using for friends
03-10 02:07:56.401: W/System.err(19803): net.sqlcipher.database.SQLiteException: error code 8: attempt to write a readonly database
03-10 02:07:56.401: W/System.err(19803): at net.sqlcipher.database.SQLiteStatement.native_execute(Native Method)
03-10 02:07:56.401: W/System.err(19803): at net.sqlcipher.database.SQLiteStatement.execute(SQLiteStatement.java:58)
03-10 02:07:56.401: W/System.err(19803): at net.sqlcipher.database.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1795)
03-10 02:07:56.401: W/System.err(19803): at net.sqlcipher.database.SQLiteDatabase.update(SQLiteDatabase.java:1725)
03-10 02:07:56.401: W/System.err(19803): at com.baidu.hi.database.FriendsDBUtil.updateFriendsUFlag(FriendsDBUtil.java:466)
03-10 02:07:56.401: W/System.err(19803): at com.baidu.hi.logic.FriendLogic.updateFriendsUFlag(FriendLogic.java:480)
03-10 02:07:56.401: W/System.err(19803): at com.baidu.hi.logic.LoginLogic.loginSuccess(LoginLogic.java:592)
03-10 02:07:56.401: W/System.err(19803): at com.baidu.hi.logic.LoginLogic.doLoginSuccessProcess(LoginLogic.java:1826)
03-10 02:07:56.401: W/System.err(19803): at com.baidu.hi.logic.SqliteCipherLogic$3.dataTransferCompleted(SqliteCipherLogic.java:309)
03-10 02:07:56.401: W/System.err(19803): at com.baidu.hi.logic.SqliteCipherLogic.doEncryptedProcess(SqliteCipherLogic.java:204)
03-10 02:07:56.401: W/System.err(19803): at com.baidu.hi.logic.SqliteCipherLogic.doUserEncryptedProcess(SqliteCipherLogic.java:295)
03-10 02:07:56.401: W/System.err(19803): at com.baidu.hi.net.NetManager$2$2.run(NetManager.java:624)
03-10 02:07:56.401: W/System.err(19803): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
03-10 02:07:56.401: W/System.err(19803): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
03-10 02:07:56.401: W/System.err(19803): at java.lang.Thread.run(Thread.java:841)

We can reproduce it with following steps:
1.Database Migration to the encrypted version from unencrypted version.
2.User database will start data migration when login.
3.Application startup without successful migration for the first time, continue to use the not encrypted database
4.This time logout and login again completed data migration, access to the encrypted database will appear this crash above.

has been Fixed it!!!

1 Like

@weilixin_tom how to fix it? Could you give me some tips? Thank you!:slight_smile:

Iā€™m facing the same issue, App is crashing after migration is completed and I login again. App is crashing only once. It is working fine after restarting the app.
Can you please help me, how to fix this crash?
Thank you in advance.

Error logs: net.sqlcipher.database.SQLiteException: error code 8: attempt to write a readonly database

Hello @Bhavik_Sadiwala

This may be due to an application integration/usage issue. To attempt to isolate your application logic from the behavior you are seeing it would be helpful to have a separate reproduction case. Would you create a reproduction case within the SQLCipher for Android test suite? We would be happy to review the situation.