Skip to content

Instantly share code, notes, and snippets.

@ar-android
Created October 30, 2017 15:25
Show Gist options
  • Save ar-android/1dcccb57cce7d029f0818ab45fd61924 to your computer and use it in GitHub Desktop.
Save ar-android/1dcccb57cce7d029f0818ab45fd61924 to your computer and use it in GitHub Desktop.
private ArrayList<String> getAllShownImagesPath(Activity activity) {
Uri uri;
Cursor cursor;
int column_index_data;
ArrayList<String> listOfAllImages = new ArrayList<String>();
String absolutePathOfImage = null;
uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
String[] projection = {MediaStore.MediaColumns.DATA,
MediaStore.Images.Media.BUCKET_DISPLAY_NAME};
cursor = activity.getContentResolver().query(uri, projection, null,
null, null);
assert cursor != null;
column_index_data = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
while (cursor.moveToNext()) {
absolutePathOfImage = cursor.getString(column_index_data);
listOfAllImages.add(absolutePathOfImage);
}
return listOfAllImages;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment