code clean up [Daniel Gultsch]

This commit is contained in:
12aw 2022-03-19 17:30:02 +01:00
parent db3a73bf42
commit f607cee55f

View file

@ -584,11 +584,15 @@ public final class MimeUtils {
}
private static String getDisplayName(final Context context, final Uri uri) {
try (Cursor cursor = context.getContentResolver().query(uri, null, null, null, null)) {
try (final Cursor cursor = context.getContentResolver().query(uri, null, null, null, null)) {
if (cursor != null && cursor.moveToFirst()) {
return cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
final int index = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
if (index == -1) {
return null;
}
return cursor.getString(index);
}
} catch (Exception e) {
} catch (final Exception e) {
return null;
}
return null;