Code example for CursorLoader

Methods: loadInBackground

0
	 */ 
	public static String getRealPathFromUri(Uri uri, Context c) {
	    // Check in the media database 
	    try { 
    	    String[] proj = { MediaStore.Images.Media.DATA };
    	    CursorLoader loader = new CursorLoader(c, uri, proj, null, null, null);
    	    Cursor cursor = loader.loadInBackground();
    	    int index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    	    cursor.moveToFirst();
    	    return cursor.getString(index);
	    } 
	    // Otherwise it must be a fresh camera image 
	    // Just use the raw path from the Uri 
	    catch (Exception e) {
	        return uri.getPath();
	    } 
	} 
}