I want to load all the Images present in the users device. I know that Images can be loaded using Media Store but the biggest drawback for me is that the Images which are present in the folder having .nomedia
file are not loaded/retrieved using Media Store.
Is there an efficient way using Media Store or without using Media Store to load all the Images present in Android device irrespective of their parent folder having a .nomedia
file?
This is how I am loading Images whose parent directory does not have .nomedia
file:
public void getImages(Context context) {
File Image_File;
final String[] columns = {MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID};
String orderBy = MediaStore.Images.Media.DATE_MODIFIED ;
Cursor cursor = context.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
null, orderBy);
if (cursor != null)
{
cursor.moveToFirst();
final int dataColumnIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
while (cursor.moveToNext()) {
Image_File = new File(cursor.getString(dataColumnIndex));
//Add the Image to the list
}
}
}
I know that I can scan each and every folder and check if there is a Image present in it but it would consume a lot of time.