【发布时间】:2015-12-24 15:35:11
【问题描述】:
这是我所做的:
我创建了一个列(blob 类型)并成功地将字节数组保存到其中。然后我通过这段代码得到了图像:
cursor.moveToFirst();
theme = cursor.getBlob(cursor.getColumnIndex("Theme"));
bitmap = BitmapFactory.decodeByteArray(theme, 0, theme.length);
screenBackGround.setBackground(new BitmapDrawable(getResources(), bitmap));
- 注意:只有 1 行。
第一次尝试:
- 我使用了一张 500x500 (12.6KB) 的图片,效果很好。
然后第二次尝试:
-
我使用了 768x1280 (120KB) 的图像,然后我收到了这个错误:
12-24 06:24:54.965:E/CursorWindow(1186):无法从具有 0 行 3 列的 CursorWindow 读取第 0 行第 1 列。
12-24 06:24:54.965: E/AndroidRuntime(1186): java.lang.IllegalStateException: 无法从 CursorWindow 读取第 0 行第 1 列。确保 Cursor 在从中访问数据之前已正确初始化。
我不知道为什么我会得到这个异常,我认为应该有 OutOfMemory 异常或某事,请给我解释并教我如何解决这个问题。谢谢!
【问题讨论】:
-
在第二种情况下,图像是否正确添加到数据库中??
-
是的,它已正确添加
-
添加您的查询,因为您没有得到任何检查行 0
标签: android sqlite android-contentprovider illegalstateexception