Is there any way to look for an image using the path? MediaStore.Images.Thumbnails (Android)

老子叫甜甜 提交于 2019-12-21 21:27:54

问题


I'm using MediaStore.Images.Thumbnails in order to show the images the user have. But i'm not able to get an image through its path. Is there any way to look for an image using the path?

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 

Best regards!


回答1:


EDITED

Hi,

//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, Jett



来源:https://stackoverflow.com/questions/3490623/is-there-any-way-to-look-for-an-image-using-the-path-mediastore-images-thumbnai

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!