get path to image in xamarin android

Hello everyone ..
this is my code for get path to image but doesn't work for me ,,
my question how i can get this path ?

bellow is my code

   private string GetPathToImage(Android.Net.Uri uri)
        string path = null;
        // The projection contains the columns we want to return in our query.
        string[] projection = new[] { Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data };

        using (ICursor cursor = ContentResolver.Query(uri, projection, null, null, null))
            if (cursor != null)
                int columnIndex = cursor.GetColumnIndexOrThrow(Android.Provider.MediaStore.Images.Media.InterfaceConsts.Data);
                path = cursor.GetString(columnIndex);

        return path;


please help me :(


  • minaFawzy.1775minaFawzy.1775 USMember ✭✭

    here is how you do this in Android native

    public String getRealPathFromURI(Uri uri) {
        Cursor cursor = getContentResolver().query(uri, null, null, null, null); 
        int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); 
        return cursor.getString(idx); 

    it seem the same

Sign In or Register to comment.