App crashes sometime when it reads all messages from db in background task and user perform delete operation at same time.
Stack trace:
java.lang.IllegalStateException: Couldn't read row 1426, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. at
android.database.CursorWindow.nativeGetLong(Native Method) at android.database.CursorWindow.getLong(CursorWindow.java:542) at android.database.AbstractWindowedCursor.getLong(AbstractWindowedCursor.java:77) at com.android.smslib.db.dao.MessageDao_Impl$19.call(MessageDao_Impl.java:1044) at com.android.smslib.db.dao.MessageDao_Impl$19.call(MessageDao_Impl.java:1009) at androidx.room.CoroutinesRoom$Companion$execute$2.invokeSuspend(CoroutinesRoom.kt:54) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at
DB Query:
@Query("SELECT * FROM message")
suspend fun getAllMessages(): List<Message>?