Here you can find the source of getRealPathFromURI(Activity activity, Uri contentUri)
public static String getRealPathFromURI(Activity activity, Uri contentUri)
//package com.java2s; import android.app.Activity; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; public class Main { public static String getRealPathFromURI(Activity activity, Uri contentUri) {/*from w w w. ja v a 2 s .c o m*/ String[] proj = { MediaStore.Images.Media.DATA }; Cursor cursor = activity.managedQuery(contentUri, proj, null, null, null); int column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); if (cursor.moveToFirst()) { return cursor.getString(column_index); } else { return null; } } }