代码之家  ›  专栏  ›  技术社区  ›  Terrel Lewis

房间数据库引发CursorWindowAllocationException

  •  0
  • Terrel Lewis  · 技术社区  · 6 年前

    我无法找出这个例外的原因。这是stacktrace:

    Fatal Exception: android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. 
       at android.database.CursorWindow.(CursorWindow.java:108)
       at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:226)
       at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:148)
       at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:142)
       at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219)
       at android.database.AbstractCursor.moveToNext(AbstractCursor.java:268)
       at android.arch.persistence.room.InvalidationTracker$1.checkUpdatedTable(InvalidationTracker.java:358)
       at android.arch.persistence.room.InvalidationTracker$1.run(InvalidationTracker.java:329)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
       at java.lang.Thread.run(Thread.java:764)
    

    以下是查询:

        @Query("select * from PhoneEvent where event_type=:type and 
        client_created_timestamp>=:startTimestamp and 
        client_created_timestamp<:endTimestamp")
        List<PhoneEvent> getAllPhoneEventsOfTypeAndBetween(String type, 
        long startTimestamp, long endTimestamp);
    

        final List<PhoneEvent> _result = new ArrayList<PhoneEvent>(_cursor.getCount());
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Ümañg ßürmån    6 年前

    我的解决方案: @Transaction 试试看。