private ArrayList getPathOfAll() {
ArrayList result = new ArrayList<>();
Uri uri;
String[] projection;
if (사진) {
uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
projection = new String[]{MediaStore.MediaColumns.DATA, MediaStore.MediaColumns.DISPLAY_NAME};
} else {
uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
projection = new String[]{MediaStore.Video.Media._ID, MediaStore.Video.Media.DISPLAY_NAME, MediaStore.Video.Media.DATA};
}
Cursor cursor = getContentResolver().query(uri, projection, null, null, MediaStore.MediaColumns.DATE_ADDED + " desc");
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
// int columnDisplayname = cursor.getColumnIndexOrThrow(MediaStore.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(TAG, "Path : " + string + "");
// }
return result;
}
columnIndex 값으로 더 많은 데이터를 가져올 수 있는 듯 하나 ... 좀 더 확인해보아야 할듯.?