Skip to content

Instantly share code, notes, and snippets.



Last active Oct 26, 2015
What would you like to do?
GetPathToImage Xamarin's implementation
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
if ((requestCode == PickImageId) && (resultCode == Result.Ok) && (data != null))
Uri uri = data.Data;
string path = GetPathToImage(uri);
Toast.MakeText(this, path, ToastLength.Long);
private string GetPathToImage(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 = ManagedQuery(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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.