Android examples for android.net:Uri
get Real Path From URI via MediaStore
import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Calendar; public class Main{ /**/*from ww w . j a va 2s . c o m*/ * @see http://stackoverflow.com/questions/3401579/get-filename-and-path-from-uri-from-mediastore */ public static String getRealPathFromURI(Context context, Uri contentUri) { Cursor cursor = null; try { String[] proj = { MediaStore.Images.Media.DATA }; cursor = context.getContentResolver().query(contentUri, proj, null, null, null); int column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } catch (Exception e) { return null; } finally { if (cursor != null) { cursor.close(); } } } }