Here you can find the source of getRealPathFromURI(Context context, Uri contentUri)
public static String getRealPathFromURI(Context context, Uri contentUri)
//package com.java2s; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; public class Main { public static String getRealPathFromURI(Context context, Uri contentUri) { String[] proj = { MediaStore.Images.Media.DATA }; Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null); int column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst();/*w ww . j a v a2 s . co m*/ String path = cursor.getString(column_index); cursor.close(); return path; } }