android - 尝试访问游标数据时出错

标签 android cursor

我的应用程序中有一个已填充的数据库,但我无法通过查询方法返回的游标访问数据。

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 行时,会引发此错误:

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

这就是我知道我的数据库有内容的方式:

enter image description here

我错过了什么?这是我第一次处理游标。

最佳答案

发现问题:

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

我正在将图像存储到数据库中。

我将更改我的体系结构以使用 Picasso 的离线缓存来存储来自网络服务的图像。

关于android - 尝试访问游标数据时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43990550/

相关文章:

android - 循环遍历 ArrayList 时在后台添加标记

sql - 如何使用 Pandas 中的游标执行与数据框列值的逻辑比较

Android 列 '_id' 不存在

sql - 获取当前正在执行的 SQL Cursor 语句

android - 为什么我使用相机传递结果 ResultInfo 失败?

Android:一段时间后禁用按钮

安卓 picasso : Not Loading in Fragment

java - 无法导入 Google Analytics

python - MySQLdb.cursors.Cursor.execute 在不同游标的情况下返回不同的值,为什么?

android - 使用共享 View 模型掌握细节流程