开发者

storing image into SQLite in android

hai all i want to store an image in SQLite database.that was selected from SD card.

After searching in the google i found that BLOB is the way to store image 开发者_JAVA百科in database.

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

how can i store image in the database in blob format?

can anyone give me the sample to store the image in database?

Please help me....


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);

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜