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

热点内容
程序员掉入能力陷阱 浏览:671
中百超市多点app如何充值 浏览:331
仙剑奇侠传4codex未加密 浏览:194
如何搭建服务器ss端口 浏览:62
国外代理服务器地址服务器端口密码 浏览:754
phpthrownew 浏览:681
java从入门到精通pdf百度云 浏览:55
linuxhdf5安装 浏览:469
java继承编程练习题 浏览:652
云记app怎么写字视频 浏览:598
如何进入我的世界脏小豆的服务器 浏览:42
哪里找到转转app 浏览:580
苹果二次app怎么注册 浏览:587
国际服体验服服务器为什么爆满 浏览:114
微信商城模板源码 浏览:436
网页的源码怎么读取 浏览:402
ubuntu命令打开软件 浏览:761
如何实现对讲频道加密 浏览:351
福州8000的程序员去深圳多少 浏览:645
保存加密是什么意思 浏览:43