Click here to Skip to main content
16,018,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

Java
@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);
	}


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

Thanks.

BCD
Posted
Updated 7-May-14 10:16am
v2

1 solution

Here is my code:
C#
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900