我正在使用MediaStore.Images.Thumbnails
来显示用户拥有的图片。但是我无法通过它的路径获得图像。
有没有办法使用路径查找图像?
String [] proj={MediaStore.Images.Thumbnails._ID, MediaStore.Images.Thumbnails.IMAGE_ID, MediaStore.Images.Media.DATA};
String selection = MediaStore.Images.Media.DATA + " like '%path%'"; //this doesn't work
cursor = managedQuery( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
proj, // Which columns to return
selection, // WHERE clause;
null,
null); // Order-by clause
祝你好运!
答案 0 :(得分:4)
EDITED
您好,
//I just get Image ID.
String [] proj={MediaStore.Image.Media._ID,MediaStore.Image.Media.DATA}
cursor=manageQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj,MediaStore.Images.Media.DATA+"= ' "+path+" ' ",null,null);
cursor.moveToFirst();
// and then, use ID to get thumbnails
Bitmap b=MediaStore.Images.Thumbnails.getThumbnail(cr,Integer.valueOf(cursor.getString(0)),kind, null);
// or for video
Bitmap b=MediaStore.Video.Thumbnails.getThumbnail(cr, Integer.valueOf(cursor.getString(0)),kind, null);
BR, 杰特