Code example for CursorLoader

Methods: loadInBackground

	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);
    	    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();
Stop searching for code, let great code find you!  Add Codota to your java IDE