diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-03-16 10:44:13 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-03-16 10:44:13 +0100 |
commit | 323d31ba05c3293a442932b4fde064ee401730aa (patch) | |
tree | 9d8bb8af8cf2f1bd7ead0b3fee07dfb5dddf235d /src/main/java/eu | |
parent | 678bc7b4d4ef2b42323e141985ab9a94f0829593 (diff) | |
parent | eaddfa7fd1bcbe03cc6c4c757f91af1040f876fa (diff) |
Merge pull request #1767 from fiaxh/path_file_accessible
Check if path for URI is accessible
Diffstat (limited to 'src/main/java/eu')
-rw-r--r-- | src/main/java/eu/siacs/conversations/utils/FileUtils.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/utils/FileUtils.java b/src/main/java/eu/siacs/conversations/utils/FileUtils.java index ad8b8640f..6e75d41cd 100644 --- a/src/main/java/eu/siacs/conversations/utils/FileUtils.java +++ b/src/main/java/eu/siacs/conversations/utils/FileUtils.java @@ -10,6 +10,8 @@ import android.os.Environment; import android.provider.DocumentsContract; import android.provider.MediaStore; +import java.io.File; + public class FileUtils { /** @@ -77,7 +79,14 @@ public class FileUtils { } // MediaStore (and general) else if ("content".equalsIgnoreCase(uri.getScheme())) { - return getDataColumn(context, uri, null, null); + String path = getDataColumn(context, uri, null, null); + if (path != null) { + File file = new File(path); + if (!file.canRead()) { + return null; + } + } + return path; } // File else if ("file".equalsIgnoreCase(uri.getScheme())) { |