1.創建的圖片儲存字段對應類型爲blob;
對應的bitmap類型的圖片取到後採用流的形式寫到數據庫,bitmap 變爲 Blob;
ByteArrayOutputStream os = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG,
100, os);
存儲的具體內容爲os.toByteArray();
2.從數據庫讀取圖片
cursor爲數據庫查詢後所得遊標
bitmap爲數據庫字段名
byte[] in=cursor.getBlob(cursor.getColumnIndex(“bitmap”));
bm=BitmapFactory.decodeByteArray(in,0,in.length);