DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

unexpected SQLiteReadOnlyDatabaseException

Open battlmonstr opened this issue 11 years ago • 4 comments

This exception has happened much after the database was opened and used. I initialize DBFlow on startup. Then I was using DBFlow for both reading and writing for a while (just several selects, inserts and updates without any stress). Then after a short pause on a new update this happened. I can't reproduce it anymore, so I assume that it's rare. It's still very important to fix, because it crashes the whole app.

E/SQLiteLog(15743): (1032) statement aborts at 45: [UPDATE  OR ABORT MyModel SET x=?,y=?,z=? WHERE `id`='...'
Caused by: android.database.sqlite.SQLiteReadOnlyDatabaseException: attempt to write a readonly database (code 1032)
    at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native Method)
    at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:734)
    at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
    at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
    at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1576)
    at com.raizlabs.android.dbflow.SQLiteCompatibilityUtils.updateWithOnConflict(SQLiteCompatibilityUtils.java:63)
    at com.raizlabs.android.dbflow.sql.SqlUtils.update(SqlUtils.java:289)
    at com.raizlabs.android.dbflow.sql.SqlUtils.save(SqlUtils.java:264)
    at com.raizlabs.android.dbflow.structure.ModelAdapter.save(ModelAdapter.java:54)
    at com.raizlabs.android.dbflow.structure.BaseModel.save(BaseModel.java:50)
    ...

battlmonstr avatar Sep 10 '15 09:09 battlmonstr

It will happen if you call FlowManager.init more than one time for the same app. Be sure to only call that method one time.

andrecrispim avatar Sep 10 '15 20:09 andrecrispim

It's only called once on startup. This exception has happened after using DBFlow for a while, and I don't mess with the database in any other way (it's never closed or reopened).

battlmonstr avatar Sep 11 '15 13:09 battlmonstr

check if this isn't related to #238

bryant1410 avatar Nov 09 '15 12:11 bryant1410

this is most likely outdated.

agrosner avatar May 03 '16 19:05 agrosner