Error when trying to access Cursor data

孤街浪徒 提交于 2019-12-05 06:23:07

问题


I have a populated Database in my app but I'm having trouble to access data through a returned cursor from the query method.

Cursor query = getContentResolver().query(MoviesContract.MoviesEntry.CONTENT_URI,
        null,
        null,
        null,
        null);

query.moveToFirst();

while (query.isAfterLast() == false){
    Log.d("Test", query.getString(0));
    query.moveToNext();
}

I'm doing tests on this block of code. When I execute the Log.d line, this error is raised:

java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.

This is how I know my database has content:

What I'm missing? It's my first time dealing with cursors.


回答1:


Found the problem:

CursorWindow: Window is full: requested allocation 1369680 bytes, free space 596540 bytes, window size 2097152 bytes

I was storing images into the Database.

I'm going to change my architecture to store the image from the webservice with the Offline Caching of Picasso.



来源:https://stackoverflow.com/questions/43990550/error-when-trying-to-access-cursor-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!