如何获取android中的相册列表 [英] How to get a list of photo albums in android

查看:1271
本文介绍了如何获取android中的相册列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我为我的应用程序实现了一个自定义库,允许用户一次选择多个图像。首先向用户显示有效相册的列表,然后当用户选择相册时,仅显示该相册中的图像。之前的代码只能加载有效的相册。



Hello

I'am implementing a custom gallery for my app which allows users to select multiple images at once. The user is first shown a list of valid photo albums and then when the user selects the album only the images in that album should be displayed. The code before should only load valid photo albums.

@Override
	public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
		
	   final String[] projection = {
	            MediaStore.Images.Media.BUCKET_DISPLAY_NAME };

		final String orderBy = MediaStore.Images.Media.DATE_ADDED;
		
		return new CursorLoader(getActivity(),MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, orderBy);
	}





问题是,光标会加载所有图像,我只想要一个存储桶名称列表。我该怎么办呢?



谢谢。



BCD



The problem is, the cursor loads all images, I just want a list of bucket names. How can I go about this?

Thanks.

BCD

推荐答案

这是我的代码:

Here is my code:
private static final Uri mBaseUri = Files.getContentUri(EXTERNAL_MEDIA);
private static final String[] PROJECTION_BUCKET = {
            ImageColumns.BUCKET_ID,
            FileColumns.MEDIA_TYPE,
            ImageColumns.BUCKET_DISPLAY_NAME };
Cursor cursor = mApplication.getContentResolver().query(
                mBaseUri, PROJECTION_BUCKET, null, null, null);



试一试。


Have a try.


这篇关于如何获取android中的相册列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆