aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java18
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;
}
}