Skip to content

Instantly share code, notes, and snippets.

@r4hulp
Created October 26, 2015 17:15
Show Gist options
  • Save r4hulp/120871b635bf8b34cac4 to your computer and use it in GitHub Desktop.
Save r4hulp/120871b635bf8b34cac4 to your computer and use it in GitHub Desktop.
Our Implementation GetPathToImage - Part 2
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);
if (document_id.Contains(":"))
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