Java tutorial
//package com.java2s; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; import android.util.Log; public class Main { public static String getRealPathFromURI(Context context, Uri contentURI) { String TAG = "PINGUINO-getRealPathFromURI"; String result; Cursor cursor = context.getContentResolver().query(contentURI, null, null, null, null); if (cursor == null) { result = contentURI.getPath(); } else { Log.d(TAG, "cursor1:" + cursor); cursor.moveToFirst(); Log.d(TAG, "cursor2:" + cursor); int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); Log.d(TAG, "idx:" + idx); result = cursor.getString(idx); Log.d(TAG, "result:" + result); cursor.close(); } return result; } }