I am using a code which is listing all the images from my device...and I'm trying to figure it out how to get images only from a specific folder, not all the images. Here is the code I'm using :
ArrayList<Bitmap> images = new ArrayList<Bitmap>();
String[] projection = {MediaStore.Images.Thumbnails.DATA};
Uri uri = Uri.parse("content://media/external/images/media");
cursor = managedQuery( uri, projection, null, null, null);
//cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
Log.i("MediaStore.Images.Media.EXTERNAL_CONTENT_URI", "MediaStore.Images.Media.EXTERNAL_CONTENT_URI: " + MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
if(cursor.getCount()==0){
Log.i("No Cards","No Cards");
cursor.close();
} else if(cursor.getCount()>0){
for(cursor.moveToFirst(); cursor.moveToNext(); cursor.isAfterLast()){
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
String imagePath = cursor.getString(columnIndex);
Log.i("imagePath", "imagePath: " + imagePath);
Bitmap b = BitmapFactory.decodeFile("/Stampii" + imagePath, null);
images.add(b);
}
}
The thing that I want to do is to get images from imagePath: /mnt/sdcard/Stampii/MediaCategory-251.jpg
Stampii folder, but I can't understand how to enter the right path to that folder. I've already tried with :
Uri uri = Uri.parse("content://media/external/images/media/mnt/sdcard/Stampii");
Any solutions?