Skip to content

Commit

Permalink
take advantage of Cursor being Closeable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcohn committed Sep 8, 2020
1 parent 80d4b9f commit 765cb5c
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -781,16 +781,12 @@ static List<FFmpegExecution> listFFmpegExecutions() {
private static String getSafParameter(Context context, Uri uri, String openMode) {

String displayName = "unknown";
final Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
try {
try (Cursor cursor = context.getContentResolver().query(uri, null, null, null, null)) {
if (cursor != null && cursor.moveToFirst()) {
displayName = cursor.getString(cursor.getColumnIndex(DocumentsContract.Document.COLUMN_DISPLAY_NAME));
}
} catch (Throwable ex) {
Log.e(TAG, "failed to get column", ex);
} finally {
if (cursor != null)
cursor.close();
}

int fd = -1;
Expand Down

0 comments on commit 765cb5c

Please sign in to comment.