Merge pull request #1767 from fiaxh/path_file_accessible

Check if path for URI is accessible
This commit is contained in:
Daniel Gultsch 2016-03-16 10:44:13 +01:00
commit 323d31ba05

View file

@ -10,6 +10,8 @@ import android.os.Environment;
import android.provider.DocumentsContract; import android.provider.DocumentsContract;
import android.provider.MediaStore; import android.provider.MediaStore;
import java.io.File;
public class FileUtils { public class FileUtils {
/** /**
@ -77,7 +79,14 @@ public class FileUtils {
} }
// MediaStore (and general) // MediaStore (and general)
else if ("content".equalsIgnoreCase(uri.getScheme())) { 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 // File
else if ("file".equalsIgnoreCase(uri.getScheme())) { else if ("file".equalsIgnoreCase(uri.getScheme())) {