【发布时间】:2017-03-10 07:13:30
【问题描述】:
我的 SQLite 表中有一个 BLOB 类型列,并且正在将可绘制图像的字节 [] 保存到其中。现在,在检索时,我正在使用光标访问 blob
cursor.getBlob(cursor.getColumnIndex(SQLiteHelper.col_product_image))
然后使用下面的代码来显示上面代码中检索到的byte[]
ByteArrayInputStream inputStream = new ByteArrayInputStream(bb);
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
iv.setImageBitmap(bitmap);
但图像视图中没有显示任何内容,因为BitmapFactory.decodeStream(inputStream);
为空。
bb的值为[91, 66, 64, 52, 51, 54, 102, 51, 53, 51, 48, 0]
救命!
【问题讨论】:
-
bb???什么是bb?您应该显示完整的可重现代码。 -
saving the byte[] of an image f检查你放入了多少字节以及你从一开始就取出了多少。
标签: android arrays image sqlite blob