'Caused by java.lang.IllegalStateException: Couldn't read row 281, col 0 from CursorWindow with Room

I am getting this exception with my DAO in Room, at what seems random moments:

Caused by java.lang.IllegalStateException
Couldn't read row 281, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
android.database.CursorWindow.nativeGetString (CursorWindow.java)
android.database.CursorWindow.getString (CursorWindow.java:460)
android.database.AbstractWindowedCursor.getString (AbstractWindowedCursor.java:51)
com.myapp.android.model.db.PlacesDao_Impl$6.call (PlacesDao_Impl.java:734)
io.soulpicks.android.model.db.PlacesDao_Impl$6.call (PlacesDao_Impl.java:693)
android.arch.persistence.room.RxRoom$4.apply (RxRoom.java:111)
android.arch.persistence.room.RxRoom$4.apply (RxRoom.java:108)
io.reactivex.internal.operators.flowable.FlowableMap$MapConditionalSubscriber.tryOnNext (FlowableMap.java:124)
io.reactivex.internal.operators.flowable.FlowableObserveOn$ObserveOnConditionalSubscriber.runAsync (FlowableObserveOn.java:637)
io.reactivex.internal.operators.flowable.FlowableObserveOn$BaseObserveOnSubscriber.run (FlowableObserveOn.java:176)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1113)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588)
java.lang.Thread.run (Thread.java:818)

Saw it reported by Crashlytics multiple times on multiple devices, but I haven't encountered the bug myself.

This is my PlaceDao class:

@Dao
interface PlacesDao {

    @Query("select * from Places where placeId = :id")
    fun getPlace(id: String): Flowable<Place>

    @Query("select * from Places where placeId in (:placesIds) order by distance, placeName ASC")
    fun getPlaces(placesIds: List<String>): Flowable<List<Place>>

    @Query("select * from Places join list_results where Places.placeId = list_results.id order by distance, placeName ASC")
    fun getFilteredPlaces(): Flowable<List<Place>>

    @Query("select * from Places where placeId = :id")
    fun forId(id: String) : Place

    @Query("select * from Places where placeId in (:placesIds)")
    fun forIds(placesIds: List<String>): List<Place>


    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun savePlaces(places: List<Place>)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun savePlace(place: Place)

    @Query("DELETE from Places")
    fun deleteAll()


    @Query("select * from Places")
    fun getAll(): Single<List<Place>>


    @Query("select * from Places where (experienceId IS NOT NULL) AND (experienceId != '') order by placeName")
    fun getMyPlaces(): Flowable<List<Place>>


    @Query("update Places set distance = :distance where placeId = :id")
    fun updateDistance(id: String, distance: Float)
}

I am having trouble figuring out how to debug it even, let alone fixing the issue!



Solution 1:[1]

I encountered similar problem too. It is because of high volume of data. Room is not intended to store high volume data (pictures etc.)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nephes Dr