aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/utils/FileUtils.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/FileUtils.java b/src/main/java/de/pixart/messenger/utils/FileUtils.java
index 83d0e9fbc..e37f0d44a 100644
--- a/src/main/java/de/pixart/messenger/utils/FileUtils.java
+++ b/src/main/java/de/pixart/messenger/utils/FileUtils.java
@@ -19,6 +19,8 @@ import de.pixart.messenger.Config;
public class FileUtils {
+ private static final Uri PUBLIC_DOWNLOADS = Uri.parse("content://downloads/public_downloads");
+
/**
* Get a file path from a Uri. This will get the the path for Storage Access
* Framework Documents, as well as the _data field for the MediaStore and
@@ -56,10 +58,12 @@ public class FileUtils {
else if (isDownloadsDocument(uri)) {
Log.d(Config.LOGTAG, "FileUtils is downloads document");
final String id = DocumentsContract.getDocumentId(uri);
- final Uri contentUri = ContentUris.withAppendedId(
- Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
-
- return getDataColumn(context, contentUri, null, null);
+ try {
+ final Uri contentUri = ContentUris.withAppendedId(PUBLIC_DOWNLOADS, Long.valueOf(id));
+ return getDataColumn(context, contentUri, null, null);
+ } catch (NumberFormatException e) {
+ return null;
+ }
}
// MediaProvider
else if (isMediaDocument(uri)) {