diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/FileBackend.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index 727892af0..350dfb7c9 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -149,17 +149,17 @@ 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()) { - long size = cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE)); - cursor.close(); - return size; - } else { - if (cursor != null) { + try { + final Cursor cursor = context.getContentResolver().query(uri, null, null, null, null); + if (cursor != null && cursor.moveToFirst()) { + long size = cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE)); cursor.close(); + return size; + } else { + return -1; } - File f = new File(uri.getPath()); - return f.length(); + } catch (Exception e) { + return -1; } } |