尝试访问游标数据时出错 [英] Error when trying to access Cursor data
问题描述
我的应用程序中有一个已填充的数据库,但无法通过查询方法中返回的游标访问数据。
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();
}
我正在对此代码块进行测试。当我执行Log.d行时,会引发此错误:
I'm doing tests on this block of code. When I execute the Log.d line, this error is raised:
java.lang.IllegalStateException:无法读取行0,col
CursorWindow中的0。在
从中访问游标之前,请确保正确初始化了游标。
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.
推荐答案
发现了问题:
CursorWindow:窗口已满:请求分配1369680字节,可用
空间596540字节,窗口大小2097152字节
CursorWindow: Window is full: requested allocation 1369680 bytes, free space 596540 bytes, window size 2097152 bytes
我正在将图像存储到数据库中。
I was storing images into the Database.
我将更改架构,以使用毕加索的离线缓存从Web服务存储图像。 。
I'm going to change my architecture to store the image from the webservice with the Offline Caching of Picasso.
这篇关于尝试访问游标数据时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!