【发布时间】:2012-04-04 11:06:54
【问题描述】:
我在 Sqlite 的 BLOB 列中插入了一个位图数据(转换后的字节 [] 数组)。
我使用这个来源来获取数据。
//Get the data
byte[] byteArray = helper.getPicture(appWidgetId);
//Change byte[] data to Bitmap
Bitmap bmPicture = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
但是android显示错误信息,它的位图是空的
所以我添加了检查源。
//Get the data
byte[] byteArray = helper.getPicture(appWidgetId);
//Check, If byte is not null
if (byteArray != null) {
//Change it to Bitmap
Bitmap bmPicture = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
}
这是完美的......
我不明白为什么添加“if source”可以加载数据。
为什么不添加'if source' can't load data.
它看起来像界面...:
【问题讨论】:
-
是你的helper.getPicture(appWidgetId);异步调用?如果不是,if 语句应该没有区别。
标签: java android sqlite null blob