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

热点内容
单片机380v接触器怎么控制 浏览:782
阿里云域名本地服务器 浏览:453
数据库地址服务器 浏览:2
路由器加密码登录不上 浏览:813
qq可以加密密码 浏览:854
网上认证无法连接网站服务器地址 浏览:920
java数据库建表 浏览:172
linux本地端口 浏览:36
邮票目录pdf 浏览:378
解压笔真的有用吗 浏览:538
plc语法和编程语句 浏览:115
南航app学生旅行产品在哪里 浏览:240
漫画pdf网盘 浏览:495
手机pdf字太小 浏览:892
解压缩安装图解 浏览:257
安卓如何查看运行服务器 浏览:681
土质学pdf 浏览:995
邮箱收发服务器地址 浏览:144
web前端和python 浏览:639
寻址算法 浏览:783