public static class BucketInfo{//一个相册对象
public int bucket_id;
public String bucket_display_name;
public String thumb_data;
public int count;
public List<PhotoInfo> innerItem;
}
public static List<BucketInfo> test(ContentResolver cr) {
List<BucketInfo> list = new ArrayList<BucketInfo>();
Cursor cs = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String[]{
"_data", "date_added", "_id", "bucket_id",
"bucket_display_name"}, MediaStore.Images.Media.MIME_TYPE + " like ?",
new String[]{
"image/%"}, "date_added DESC");
if (cs == null) {
try {
cs.close();
} catch (Exception e) {
}
return list;
}
int count = cs.getCount();
HashMap<Integer, BucketInfo> hmap = new HashMap<Integer, BucketInfo>();
cs.moveToFirst();
//all photos
BucketInfo bucketinfo_allPhotos = new BucketInfo();
bucketinfo_allPhotos.bucket_display_name = GalleryDataServer.ALL_PHOTO_BUCKET_NAME;
bucketinfo_allPhotos.bucket_id = GalleryDataServer.ALL_PHOTO_BUCKET_ID;
bucketinfo_allPhotos.innerItem = new ArrayList<PhotoInfo>()
查询数据库的图片并且按照相册分组,其中包括全部图片
最新推荐文章于 2021-01-19 16:14:52 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)