diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-11-21 20:13:59 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-11-21 20:13:59 +0100 |
commit | c1f7b4e4227b91749e8f689cd9bed684284f3b47 (patch) | |
tree | 7427724315e0913e8c9b913421c708f9f8f75b07 /src/main/java | |
parent | 51b878f749a367904cf9af4a5560ccd7443e3ed1 (diff) |
catch rare exception when transforming download uri to real path
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/FileUtils.java | 12 |
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)) { |