java.lang.NullPointerException: uri
<p>Im trying to get the URI for the captured image from camera I why am i getting the exception as java.lang.NullPointerException: uri ,</p>

<p>here is my code.</p>

<pre><code>Uri selectedImage = data.getData();


file = new File(URI(selectedImage)); 

public String URI(Uri contentUri)
 {
        Cursor cursor = null;

try
 {




String[] proj = {MediaStore.ACTION_IMAGE_CAPTURE};

     cursor=getActivity().getContentResolver().query(contentUri,proj,null,null,null);
      intcolumn_index=cursor.getColumnIndexOrThrow(MediaStore.ACTION_IMAGE_CAPTURE);
            cursor.moveToFirst();
            return cursor.getString(column_index);
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
</code></pre>