Skip to content

Instantly share code, notes, and snippets.

@r4hulp
Last active October 26, 2015 17:07
Show Gist options
  • Save r4hulp/bf07a6e5ccecd532b651 to your computer and use it in GitHub Desktop.
Save r4hulp/bf07a6e5ccecd532b651 to your computer and use it in GitHub Desktop.
Our implementation of GetPathToImage - Part 1
private string GetPathToImage(Android.Net.Uri uri)
{
ICursor cursor = this.ContentResolver.Query(uri, null, null, null, null);
cursor.MoveToFirst();
string document_id = cursor.GetString(0);
document_id = document_id.Split(':')[1];
cursor.Close();
cursor = ContentResolver.Query(
Android.Provider.MediaStore.Images.Media.ExternalContentUri,
null, MediaStore.Images.Media.InterfaceConsts.Id + " = ? ", new String[] { document_id }, null);
cursor.MoveToFirst();
string path = cursor.GetString(cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Data));
cursor.Close();
return path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment