导航:首页 > 操作系统 > android数据库存储图片

android数据库存储图片

发布时间:2023-06-15 08:09:20

android图片存取数据库

1、存图片路径
2、存图片二进制(sqllite blob的数据类型)
3、存图片Uri

❷ android怎么将图片传送到服务器,然后将图片保存在mysql数据库中

一般数据库中是不保存图片的,保存的是图片存放路径,图片放到文件夹中,如果放到数据库中数据库会很大,影响读取速度。
如果想放就把字段定义为如:`img` longblob;
然后就可以读取文件流 存储到数据库中了就可以了

❸ android 如何获取保存的图片的地址 并存到数据库中

安卓中如何获取保存的图片uri 并保存到sqlite数据库中
有如下两种方法,仅供参考
方法一:java代码

public void saveIcon(Bitmap icon) {
if (icon == null) {
return;
}
// 最终图标要保存到浏览器的内部数据库中,系统程序均保存为SQLite格式,Browser也不例外,因为图片是二进制的所以使用字节数组存储数据库的
// BLOB类型
final ByteArrayOutputStream os = new ByteArrayOutputStream();
// 将Bitmap压缩成PNG编码,质量为100%存储
icon.compress(Bitmap.CompressFormat.PNG, 100, os);
// 构造SQLite的Content对象,这里也可以使用
raw ContentValues values = new ContentValues();
// 写入数据库的
Browser.BookmarkColumns.TOUCH_ICON字段 values.put(Browser.BookmarkColumns.TOUCH_ICON, os.toByteArray());
DBUtil.update(....);
//调用更新或者插入到数据库的方法
}
}

方法二:如果数据表入口时一个content:URIJava代码

import android.provider.MediaStore.Images.Media;
import android.content.ContentValues;
import java.io.OutputStream;
// Save the name and description of an image in a ContentValues map.
ContentValues values = new ContentValues(3);
values.put(Media.DISPLAY_NAME, "road_trip_1");
values.put(Media.DESCRIPTION, "Day 1, trip to Los Angeles");
values.put(Media.MIME_TYPE, "image/jpeg");
// Add a new record without the bitmap, but with the values just set.
// insert() returns the URI of the new record.
Uri uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
// Now get a handle to the file for that record, and save the data into it.
// Here, sourceBitmap is a Bitmap object representing the file to save to the database.
try {
OutputStream outStream = getContentResolver().openOutputStream(uri);
sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 50, outStream);
outStream.close();
} catch (Exception e) {
Log.e(TAG, "exception while writing image", e);
}
原文请看http://www.bafenbaosoft.com/post/48.html

❹ android端获取数据库,服务器上储存的图片怎么做

通过http请求获取服务端返回的图片地址,再通过地址获取图片。。。

阅读全文

与android数据库存储图片相关的资料

热点内容
靠算法买彩票 浏览:489
程序员考核d 浏览:237
自助游中国pdf 浏览:738
安卓p40是什么手机 浏览:79
24cxx编程器 浏览:583
阴阳师如何查看哪个服务器有ID 浏览:308
公务员照片压缩 浏览:450
编译的时候怎么找未定义的函数 浏览:344
有什么我的世界服务器 浏览:298
服务器亮绿灯是什么意思 浏览:629
python画的图如何保存高清版 浏览:491
10的搭接还用加密吗 浏览:365
bytedance这个文件夹是什么意思呢 浏览:589
算法站的客体 浏览:78
src文件夹c语言怎么运行 浏览:25
怎么把已安装的app放到桌面 浏览:948
如何查看苹果手机app是否取消订阅 浏览:774
u盘加密之后手机可以打开吗 浏览:47
单片机串口发射怎么回事 浏览:479
程序员假装自己很忙 浏览:800