Forum Xamarin.Android

Problem getting image path

sambishopsambishop GBMember ✭✭

Hi, i am having trouble geting the full image path. my app works fine when choosing from gallery. But if i select from Recent which its defaluted 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; }

Sign In or Register to comment.