I am creating an application wherein I need all the images in the gallery into my application that has a girdview in it. I want all the images from all the folders to appear in the gridview.
String[] proj = { MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID };
actualimagecursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, proj,
null, null, MediaStore.Images.Media.DEFAULT_SORT_ORDER);
actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID);
actualimagecursor.moveToPosition(position);
String i = actualimagecursor.getString(actual_image_column_index);
I have added this code into my code but i get only the sd card images no other folder images are obtained. How can i get all the images from the gallery?
Thanks in advance.
Download the source code from here (Get all images from gallery in android programmatically)
activity_main.xml
MainActivity.java
adapter_photosfolder.xml
Adapter_PhotosFolder.java
Model_images.java
AndroidManifest.xml
You can not get results with just one query, try to instantiate two different Cursors. Since you have already added EXTERNAL_CONTENT_URI, here is another:
Working solution with the help of Glide. Bonus part is Glide will auto play Gif .
Layout file for gridView
You are using
MediaStore.Images.Media.EXTERNAL_CONTENT_URI
which is only the external storage.For the internal there isMediaStore.Images.Media.INTERNAL_CONTENT_URI
. You can use a MergeCursor to combine both query results.