Android examples for android.media:Media
get Media Absolute Path
import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; public class Main { public static String getMediaAbsolutePath(Context ctx, Uri uri) { String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = ctx.getContentResolver().query(uri, filePathColumn, null, null, null); if (cursor == null || cursor.getCount() == 0) return null; cursor.moveToFirst();/* w ww . j a v a2s . co m*/ int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String picturePath = cursor.getString(columnIndex); cursor.close(); return picturePath; } }