导航:首页 > 操作系统 > 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数据库存储图片相关的资料

热点内容
windows下mysql命令 浏览:923
冰箱压缩机制冷剂与润滑 浏览:988
在线充值平台源码 浏览:527
数字图像处理冈pdf 浏览:380
荣耀v6怎么隐藏桌面文件夹 浏览:798
程序员有女的吗 浏览:504
通讯服务器中断是为什么 浏览:644
itextpdf乱码 浏览:641
哪个app制作书法壁纸 浏览:196
暗梁支坐是否加密 浏览:341
51单片pdf 浏览:688
matlab编程习题 浏览:64
腾达wifi加密方式 浏览:121
ug平移命令 浏览:768
钉钉语音通话安全加密有什么特征 浏览:609
网购领券app哪个好靠谱 浏览:618
人民币数字加密币转账支付货币 浏览:634
怎么用cat命令创建mm 浏览:689
当今社会程序员好做吗 浏览:222
程序员那么可爱梓童第几集求婚 浏览:708