diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-02-02 22:08:58 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-02-02 22:08:58 +0100 |
commit | 22ccfc3092f6c5a4cdfff74f15672df9189ba244 (patch) | |
tree | f331f3e58298e8bc28a2251279ef3a1a02da8b52 /src/main/java/de/pixart/messenger/persistance | |
parent | 0c26ea445fbc8b357f7c35221b0da857b03faf85 (diff) |
fix detection of filesize
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance')
-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(); } } |