Ⅰ android小程序,从数据库中读取图片路径然后进行显示,不是背景图片
感觉这样应该可以,
先从数据库里面获得
这个图片的绝对路径
然后
使用UIL类
URL
url=new
URL(file:///路径);
然后得到这个文件的输入流InputStream
in=url.openStream();
然后得到此图片的位图Bitmap
bitmap=BitmapFactory.decodeStream(in);
ImageView
img=new
ImageView(this);
img.setImageBitmap(bitmap);
从网络上的话是这样,但是手机上是不是这样就不清楚了你可以试一下。
那个图片应该是要放在手机上。
Ⅱ android 如何在listView中读取数据库中记录位置的图片,跪求小例子,谢谢给位大侠
R.drawable.xxx? 存变量名不方便吧 存变量的值 然后用SimpleAdapter就行
R.drawable.xxx也行 在程序中建一个map一一映射
Ⅲ android:从数据库中取得的图片,无法显示到模拟器上
应该是你在byte【】转换成bitmap 时候 或者图片转换成byte【】数组时候出现错位等一些问题,导致图片不能正确显示, 我的图片一般都是存储路径的(把图片放在sdcard),然后显示的时候直接从路径读取,上传给服务器时候用fileInfutstream 读取指定路径下的图片 上传给服务器
Ⅳ android开发: EditText中插入的相册图片如何保存在数据库里,查看的时候又如何读取
保存一个url是个不错的方法,然后加载的时候就可以根据路径去生成一个bitmap对象,再把这个对象显示到组件上 。如果知道路径,那么显示时调用BitmapFactory.decodeFile(String pathName)这个方法就行,参数为一个路径字符串.
Ⅳ android中如何从数据库获取图片的路径
利用这个URI:content://media/internal/images
下面的链接地址很详细,我就不再这里饶舌了
主要看代码部分的380行的那个Activity
Ⅵ android 如何读取数据库中的图片
从数据库读取二进制文件
然后从二进制读取的图片信息:
byte[] picData = cursor.getBlob(cursor.getColumnIndex("pic_data"));
bitmap.setImageBitmap(BitmapFactory.decodeByteArray(picData, 0, picData.length));
Ⅶ android 存在数据库中的动态图片,如何读取出来,显示在ImageView中
实现的功能为从服务器获取图片数据,在布局页面上显示。由于图片的个数是不确定的,因此采用在布局页面中定义多个ImageView来显示图片是不合理的。
(一)首先定义布局
android:id="@+id/id_layout_movie"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
(二)加载图片显示时获取到布局文件
RelativeLayout rl_Movie = (RelativeLayout) findViewById(R.id.id_layout_movie);
(三)依次循环服务器获取的图片数据,一张一张设置图片显示的位置
//newWidth为图片显示的宽度,newHeight为图片显示的高度
RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams( newWidth, newHeight);
设置lp1.leftMargin和lp1.topMargin的值
(四)最后设置rl_Movie.addView(iv, lp1)将图片加入布局文件中
Ⅷ android开发如何把数据库中图片路径转成图片读取显示
通过流的形式就可以了。通过路径得到文件流,然后使用bitmapfactory.decodeStream 方法 得到一个bitmap 然偶通过imageView.setImageBitmap()就ok了
Ⅸ 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