FileBackend: close cursor after retrieving file size
This commit is contained in:
parent
56eb49d8cc
commit
bbfabaf930
|
@ -138,10 +138,16 @@ public class FileBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long getFileSize(Context context, Uri uri) {
|
private static long getFileSize(Context context, Uri uri) {
|
||||||
Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
|
try {
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
final Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
|
||||||
return cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE));
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
} else {
|
long size = cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE));
|
||||||
|
cursor.close();
|
||||||
|
return size;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue