From a0e7f820c6ec6ee4a6c7d7e95fe66b91ed9c62f5 Mon Sep 17 00:00:00 2001 From: Andrew Shini Date: Fri, 7 Sep 2018 18:28:44 +1000 Subject: [PATCH] Fall back to writing to file if _data column does not exist (#817) * Fall back to writting to file if _data column does not exist * Fix spelling --- .../com/reactnative/ivpusic/imagepicker/RealPathUtil.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/reactnative/ivpusic/imagepicker/RealPathUtil.java b/android/src/main/java/com/reactnative/ivpusic/imagepicker/RealPathUtil.java index dff3535..ca76d3c 100644 --- a/android/src/main/java/com/reactnative/ivpusic/imagepicker/RealPathUtil.java +++ b/android/src/main/java/com/reactnative/ivpusic/imagepicker/RealPathUtil.java @@ -146,8 +146,9 @@ class RealPathUtil { cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); if (cursor != null && cursor.moveToFirst()) { - final int index = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA); - String path = cursor.getString(index); + // Fall back to writing to file if _data column does not exist + final int index = cursor.getColumnIndex(MediaStore.MediaColumns.DATA); + String path = index > -1 ? cursor.getString(index) : null; if (path != null) { return cursor.getString(index); } else {