Blob is used to store an array of bytes in sqlite.
To convert a bitmap to an array of bytes, use the following code:
Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.thumbnail); ByteArrayOutputStream out = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.PNG, 100, out); byte[] buffer=out.toByteArray();
To save an array of bytes in blob, use the following code:
ContentValues cv=new ContentValues(); cv.put(CHUNK, buffer); //CHUNK blob type field of your table long rawId=database.insert(TABLE, null, cv); //TABLE table name
Read more about blob using the link
jeet Jul 26 '12 at 4:45 2012-07-26 04:45
source share