You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/09/26 21:53:05 UTC

android commit: Guard against null pointer exception in ES File Explorer being used to get a picture

Updated Branches:
  refs/heads/master 54caa6e43 -> 1b4096b01


Guard against null pointer exception in ES File Explorer being used to get a picture


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/1b4096b0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/1b4096b0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/1b4096b0

Branch: refs/heads/master
Commit: 1b4096b01db41de633aeadd3e2fae43111722d97
Parents: 54caa6e
Author: Simon MacDonald <si...@gmail.com>
Authored: Wed Sep 26 15:52:37 2012 -0400
Committer: Simon MacDonald <si...@gmail.com>
Committed: Wed Sep 26 15:52:37 2012 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/FileUtils.java |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/1b4096b0/framework/src/org/apache/cordova/FileUtils.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java
index 1c8f084..cbeff98 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;
+        }
+        
     }
 }