Saving image in SQLite in android

hai is all i want to save image in SQLite database. This has been selected from the SD card.

After searching google, I found that BLOB is a way to save an image in a database.

link to insert, but it does not work for me, how to convert image to blob?

How can I save an image in a database in blob format?

can someone give me a sample for storing an image in a database?

Please help me....

+4
source share
1 answer
Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.thumbnail); ByteArrayOutputStream out = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.PNG, 100, out); ContentValues cv = new ContentValues(); cv.put(KEY_IMAGE, out.toByteArray()); db.insert(DB_TABLE, null, cv); 

Full example http://www.anddev.org/png_image_--und-gt_sqlite_db_--und-gt_imageview-t7188.html

+4
source

All Articles