Java tutorial
//package com.java2s; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; public class Main { /** * This method to get real path from uri. * * @param context * @param contentURI * @return imagepath */ public static String getRealPathFromURI(Context context, Uri contentURI) { Cursor cursor = context.getContentResolver().query(contentURI, null, null, null, null); if (cursor == null) { return contentURI.getPath(); } else { cursor.moveToFirst(); int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); return cursor.getString(idx); } } }