我有一个图像uri使用这个uri我在sqlite数据库中插入图像,但问题是如何检索图像。
这是代码:
if(data!=null){
Uri uri = data.getData();
try {
InputStream inputStream = getContentResolver().openInputStream(uri);
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
Bitmap bmp = BitmapFactory.decodeStream(bufferedInputStream);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, bos);
byte[] bArray = bos.toByteArray();
DataBase dataBase=new DataBase(getBaseContext());
dataBase.insertImage(bArray);
Toast.makeText(getBaseContext(),"single item ",Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
我想要重温图像??
答案 0 :(得分:0)
android docs:
abstract byte [] getBlob(int columnIndex)返回值 请求列作为字节数组。
示例:
Cursor resultSet = mydatbase.rawQuery("Select * from TutorialsPoint",null);
resultSet.moveToFirst();
byte[] raw_image = resultSet.getBlob(1)