As i am working on displaying images saved in sdcard folder, I found the following link.
Displaying images in gridview from SDCard.
I am using the following code to get images from specified folder in sdcard,but here i am getting 0 count.
MyCode.jav
String[] projection = {MediaStore.Images.Media._ID};
final String[] columns = { MediaStore.Images.Media.DATA,MediaStore.Images.Media._ID };
final String orderBy = MediaStore.Images.Media._ID;
Cursor imagecursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection,
MediaStore.Images.Media.DATA + " like ? ",
new String[] {"/my_images"},
null);
int image_column_index = imagecursor.getColumnIndex(MediaStore.Images.Media._ID);
this.count = imagecursor.getCount();
this.thumbnails = new Bitmap[this.count];
this.arrPath = new String[this.count];
this.thumbnailsselection = new boolean[this.count];
for (int i = 0; i < this.count; i++) {
imagecursor.moveToPosition(i);
int id = imagecursor.getInt(image_column_index);
int dataColumnIndex = imagecursor
.getColumnIndex(MediaStore.Images.Media.DATA);
thumbnails[i] = MediaStore.Images.Thumbnails.getThumbnail(
getApplicationContext().getContentResolver(), id,
MediaStore.Images.Thumbnails.MICRO_KIND, null);
arrPath[i] = imagecursor.getString(dataColumnIndex);
}
imageAdapter = new ImageAdapter();
secure_gallery_grid.setAdapter(imageAdapter);
imagecursor.close();
But here as per the following link all the images saved in sd card are displaying. But here i want to display images which are saved in particular folder, as like i created "My_images" folder & saved images in that folder. I want to display images from that folder & need to display in gridview as per link.
Use Universal Image Loader
https://github.com/nostra13/Android-Universal-Image-Loader.git
Give Image url as your sd card image path.
it is not possible to display particular folder images using the mediastore method. because every images stored in the mediastore has different unique id to identify it.
but you can do by create your own method to identify what are the images in the particular folder and then get the create thumbnail images.
You can get the path of files from a particualr folder as below
Once you get the path of files you ca display the images in gridview
Remember to add permissionin manifest file
By having write permission will have read permission by default.
Example
main.xml
gelleryitem.xml
AndroidCustomGalleryActivity.java
Snap shot
Here I am posting code to retrieve file names from "particular directory". You need to do some other task your self.
Now check whether "files[]" is null or not.
You have list of files with their path, fetch out bitmap from them and display in grid.
NoTe:
To print full path use following code.