Last active
October 26, 2015 17:07
-
-
Save r4hulp/bf07a6e5ccecd532b651 to your computer and use it in GitHub Desktop.
Our implementation of GetPathToImage - Part 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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