I googled and searched for all image files and found this data.
private ArrayList<String> getPathOfAllImages()
{
ArrayList<String> result = new ArrayList<>();
Uri uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
String[] projection = { MediaColumns.DATA, MediaColumns.DISPLAY_NAME };
Cursor cursor = getContentResolver().query(uri, projection, null, null, MediaColumns.DATE_ADDED + " desc");
int columnIndex = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
int columnDisplayname = cursor.getColumnIndexOrThrow(MediaColumns.DISPLAY_NAME);
int lastIndex;
while (cursor.moveToNext())
{
String absolutePathOfImage = cursor.getString(columnIndex);
String nameOfFile = cursor.getString(columnDisplayname);
lastIndex = absolutePathOfImage.lastIndexOf(nameOfFile);
lastIndex = lastIndex >= 0 ? lastIndex : nameOfFile.length() - 1;
if (!TextUtils.isEmpty(absolutePathOfImage))
{
result.add(absolutePathOfImage);
}
}
for (String string : result)
{
Log.i("PhotoSelectActivity.java | getPathOfAllImages", "|" + string + "|");
}
return result;
}
© 2024 OneMinuteCode. All rights reserved.