Forum Xamarin Xamarin.Android

Problem getting image path

sambishopsambishop GBMember ✭✭

Hi, i am having trouble getting the full image path. my app works fine when choosing from gallery. But if i select from Recent which its defaulted to load on the URI changes to "content://" and i cant get the full image path. any ideas or is there a way i can lock the user to only click on images from the gallery.

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)) //ManagedQuery(uri, projection, null, null, null)) { if (cursor != null) { int columnIndex = cursor.GetColumnIndexOrThrow(projection[0]); cursor.MoveToFirst(); path = cursor.GetString(columnIndex); } } return path; }


  • MommMomm USMember ✭✭✭

    What are you passing as your Uri?

    I've worked using it on Xamarin.Forms as DependencyService, my Uri is set to MediaStore.Images.Media.ExternalContentUri and I had no problems so far.

  • sambishopsambishop GBMember ✭✭

    If I select an image from gallery, the uri is set to "content://media/images/54" but when I click on recent the uri is set to and can't get the file path. Any ideas ? If I could just load the intent to show gallery would be a possibility, or could get the uri to read full file path from

  • XamarinDoctusXamarinDoctus COMember ✭✭


  • praveenaHMpraveenaHM USMember ✭✭

    Hello Team,

    I want image path when selected image from the gallery in xamarin android. Working in xamarin forms platform specific code. I have tried package in xamarin forms didn't worked.i have to set the path to image source in xamarin forms. Please anyone help me.

Sign In or Register to comment.