title: How correclty get real file path from URI?
body: <p>I try get real file path from URI after taking photo from camera. I do this:</p>
  
  <pre><code>private String getRealPathFromURI(Uri contentURI) {
      Cursor cursor = getContentResolver().query(contentURI, null, null, null, null); 
      cursor.moveToFirst(); 
      int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); 
      return cursor.getString(idx); 
  }
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code> public String getRealPathFromURI(Uri contentUri) {
       String[] proj = { MediaColumns.DATA };
       Cursor cursor = managedQuery(contentUri, proj, null, null, null);
       int column_index = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
       cursor.moveToFirst();
       return cursor.getString(column_index);
       }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>private String getRealPathFromURI(Uri selectedVideoUri) {
      String filePath;
      final String[] filePathColumn = new String[] { MediaColumns.DATA };
  
      Cursor cursor = getContentResolver().query(selectedVideoUri,
              filePathColumn, null, null, null);
      cursor.moveToFirst();
  
      int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
      filePath = cursor.getString(columnIndex);
      cursor.close();
      return filePath;
  }
  </code></pre>
  
  <p>on most phones, everything is working correctly. But in some phones app crashes with error:</p>
  
  <pre><code>08-03 14:55:13.092: E/AndroidRuntime(1676):     at com.android.internal.app.AlertController$ButtonHandler.handleMessage(SourceFile:190)
  08-03 14:55:13.092: E/AndroidRuntime(1676):     at android.os.Handler.dispatchMessage(SourceFile:130)
  08-03 14:55:13.092: E/AndroidRuntime(1676):     at android.os.Looper.loop(SourceFile:351)
  08-03 14:55:13.092: E/AndroidRuntime(1676):     at android.app.ActivityThread.main(SourceFile:4070)
  08-03 14:55:13.092: E/AndroidRuntime(1676):     at java.lang.reflect.Method.invokeNative(Native Method)
  08-03 14:55:13.092: E/AndroidRuntime(1676):     at java.lang.reflect.Method.invoke(Method.java:538)
  08-03 14:55:13.092: E/AndroidRuntime(1676):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(SourceFile:901)
  08-03 14:55:13.092: E/AndroidRuntime(1676):     at com.android.internal.os.ZygoteInit.main(SourceFile:659)
  08-03 14:55:13.092: E/AndroidRuntime(1676):     at dalvik.system.NativeStart.main(Native Method)
  08-03 14:55:19.823: I/System.out(1728): --MyLocationListener is created!
  08-03 14:55:19.838: D/AndroidRuntime(1728): Shutting down VM
  08-03 14:55:19.838: W/dalvikvm(1728): threadid=1: thread exiting with uncaught exception (group=0x4001c648)
  08-03 14:55:19.842: E/AndroidRuntime(1728): FATAL EXCEPTION: main
  08-03 14:55:19.842: E/AndroidRuntime(1728): java.lang.RuntimeException: Unable to create service com.webparadox.tonquer.MyLocationListener: java.lang.NullPointerException
  08-03 14:55:19.842: E/AndroidRuntime(1728):     at android.app.ActivityThread.handleCreateService(SourceFile:2221)
  08-03 14:55:19.842: E/AndroidRuntime(1728):     at android.app.ActivityThread.access$2500(SourceFile:160)
  </code></pre>
  
  <p>Help Me to fix this bug, please</p>