diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 886e764bed..a83b7f24d1 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -37,6 +37,7 @@
+
0 && cursor.moveToFirst()) {
}
ArrayList recentFiles = new ArrayList<>(20);
- final String[] projection = {MediaStore.Files.FileColumns.DATA};
+ final String[] projection = {
+ MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.DATE_MODIFIED
+ };
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_YEAR, c.get(Calendar.DAY_OF_YEAR) - 2);
Date d = c.getTime();
- Cursor cursor =
- context
- .getContentResolver()
- .query(
- MediaStore.Files.getContentUri("external"),
- projection,
- null,
- null,
- MediaStore.Files.FileColumns.DATE_MODIFIED + " DESC LIMIT 20");
+ Cursor cursor;
+ if (SDK_INT >= Q) {
+ Bundle queryArgs = new Bundle();
+ queryArgs.putInt(ContentResolver.QUERY_ARG_LIMIT, 20);
+ queryArgs.putStringArray(
+ ContentResolver.QUERY_ARG_SORT_COLUMNS,
+ new String[] {MediaStore.Files.FileColumns.DATE_MODIFIED});
+ queryArgs.putInt(
+ ContentResolver.QUERY_ARG_SORT_DIRECTION,
+ ContentResolver.QUERY_SORT_DIRECTION_DESCENDING);
+ cursor =
+ context
+ .getContentResolver()
+ .query(MediaStore.Files.getContentUri("external"), projection, queryArgs, null);
+ } else {
+ cursor =
+ context
+ .getContentResolver()
+ .query(
+ MediaStore.Files.getContentUri("external"),
+ projection,
+ null,
+ null,
+ MediaStore.Files.FileColumns.DATE_MODIFIED + " DESC LIMIT 20");
+ }
if (cursor == null) return recentFiles;
if (cursor.getCount() > 0 && cursor.moveToFirst()) {
do {