title: How to get file path from uri?
body: <p>I am trying to retrieve file path from URI. But my cursor is returning null. </p>
  
  <p>Two problems:</p>
  
  <ol>
  <li>Uri may be audio/ video. So how can I retrieve file path.</li>
  <li>Why cursor is returning null?</li>
  </ol>
  
  <p>Here is my code</p>
  
  <pre><code>    String[] proj = { MediaStore.Video.Media.DATA };
      Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null);
      //here cursor is null. So i am getting Null pointer exception             
      int column_index = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
      cursor.moveToFirst();
      return cursor.getString(column_index);  
  </code></pre>
  
  <p>Permissions I have used:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/&gt;
  </code></pre>