From 1b4096b01db41de633aeadd3e2fae43111722d97 Mon Sep 17 00:00:00 2001 From: Simon MacDonald Date: Wed, 26 Sep 2012 15:52:37 -0400 Subject: [PATCH] Guard against null pointer exception in ES File Explorer being used to get a picture --- framework/src/org/apache/cordova/FileUtils.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java index 1c8f0841..cbeff98a 100755 --- a/framework/src/org/apache/cordova/FileUtils.java +++ b/framework/src/org/apache/cordova/FileUtils.java @@ -1048,10 +1048,16 @@ public class FileUtils extends Plugin { */ @SuppressWarnings("deprecation") protected static String getRealPathFromURI(Uri contentUri, CordovaInterface cordova) { - String[] proj = { _DATA }; - Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null, null); - int column_index = cursor.getColumnIndexOrThrow(_DATA); - cursor.moveToFirst(); - return cursor.getString(column_index); + String uri = contentUri.toString(); + if (uri.startsWith("content:")) { + String[] proj = { _DATA }; + Cursor cursor = cordova.getActivity().managedQuery(contentUri, proj, null, null, null); + int column_index = cursor.getColumnIndexOrThrow(_DATA); + cursor.moveToFirst(); + return cursor.getString(column_index); + } else { + return uri; + } + } }