diff --git a/src/android/FileHelper.java b/src/android/FileHelper.java index 59f890e..f772061 100644 --- a/src/android/FileHelper.java +++ b/src/android/FileHelper.java @@ -80,18 +80,25 @@ public class FileHelper { public static String getRealPathFromURI_API19(Context context, Uri uri) { String filePath = ""; try { - String wholeID = DocumentsContract.getDocumentId(uri); - // Split at colon, use second item in the array - String id = wholeID.indexOf(":") > -1 ? wholeID.split(":")[1] : wholeID.indexOf(";") > -1 ? wholeID - .split(";")[1] : wholeID; + String id = null; + Uri myUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;; + try { + String wholeID = DocumentsContract.getDocumentId(uri); + + // Split at colon, use second item in the array + id = wholeID.indexOf(":") > -1 ? wholeID.split(":")[1] : wholeID.indexOf(";") > -1 ? wholeID + .split(";")[1] : wholeID; + } catch (Exception e) { + myUri = uri; + } String[] column = { MediaStore.Images.Media.DATA }; // where id is equal to String sel = MediaStore.Images.Media._ID + "=?"; - Cursor cursor = context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, column, + Cursor cursor = context.getContentResolver().query(myUri, column, sel, new String[] { id }, null); int columnIndex = cursor.getColumnIndex(column[0]);