我讀取drawable並將其保存到數據庫。此外,我從數據庫中讀取,但得到空。 你能幫我嗎?decodeByteArray返回null
這裏是我寫的數據庫:
BitmapDrawable drawable = (BitmapDrawable) imageResult.getDrawable();
Bitmap data = drawable.getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
data.compress(CompressFormat.JPEG, 100, stream);
db = dbHelp.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put("data", stream.toByteArray());
db.insert("table", null, cv);
這是我如何從數據庫中讀取:
db = dbHelp.getReadableDatabase();
String getProjects = "select data from table where id = (select max(id) from table);";
Cursor cu = db.rawQuery(getProjects, null);
cu.moveToFirst();
data = BitmapFactory.decodeByteArray(cu.getBlob(0), 0, cu.getBlob(0).length); //here is null
返回1行 – user3082303