diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/FileBackend.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index add0736d5..6ca53b6b4 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -148,9 +148,15 @@ public class FileBackend { private static long getFileSize(Context context, Uri uri) { Cursor cursor = context.getContentResolver().query(uri, null, null, null, null); if (cursor != null && cursor.moveToFirst()) { - return cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE)); + long size = cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE)); + cursor.close(); + return size; } else { - return -1; + if (cursor != null) { + cursor.close(); + } + File f = new File(uri.getPath()); + return f.length(); } } |