存储图像到SQLite的Andr​​oid中 [英] storing image into SQLite in android

查看:110
本文介绍了存储图像到SQLite的Andr​​oid中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

海所有我想要存储在SQLite的图像database.that从SD卡中选择。

在搜索在谷歌I发现,BLOB是存储图像数据库的方式。

这<一href="http://stackoverflow.com/questions/6028751/how-to-display-image-from-blob-data-in-android-sqlite">link随后插入,但它不为我工作, 如何将图像转换成二进制大对象?

我怎样才能在数据库中存储的图像在BLOB格式?

谁能给我样品存储图像数据库?

请帮我....

解决方案

 位图图像= BitmapFactory.de codeResource(getResources(),R.drawable.thumbnail);

ByteArrayOutputStream OUT =新ByteArrayOutputStream();

image.com preSS(Bitmap.Com pressFormat.PNG,100,出);

ContentValues​​ CV =新ContentValues​​();

cv.put(KEY_IMAGE,out.toByteArray());

db.insert(DB_TABLE,空,CV);
 

一个完整的示例的http://www.anddev.org/png_image_--und-gt_sqlite_db_--und-gt_imageview-t7188.html

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

这篇关于存储图像到SQLite的Andr​​oid中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆