Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69a1c497 authored by Fs00's avatar Fs00
Browse files

Use try-with-resources to close Cursor automatically

parent 5dce992c
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -394,18 +394,13 @@ public class MainActivity extends ProgressActivity {
    public String getFileName(Uri uri) {
        String result = null;
        if (uri.getScheme() != null && uri.getScheme().equals("content")) {
            Cursor cursor = getContentResolver().query(uri, null, null, null, null);
            try {
            try (Cursor cursor = getContentResolver().query(uri, null, null, null, null)) {
                if (cursor != null && cursor.moveToFirst()) {
                    int indexDisplayName = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
                    if (indexDisplayName != -1) {
                        result = cursor.getString(indexDisplayName);
                    }
                }
            } finally {
                if (cursor != null) {
                    cursor.close();
                }
            }
        }
        if (result == null) {