Skip to content

Instantly share code, notes, and snippets.

@rasheedsulayman
Last active April 15, 2018 09:19
Show Gist options
  • Save rasheedsulayman/f213e3b5bee91966f7ce34cb26e44ffd to your computer and use it in GitHub Desktop.
Save rasheedsulayman/f213e3b5bee91966f7ce34cb26e44ffd to your computer and use it in GitHub Desktop.
//https://stackoverflow.com/a/9989900/6484427
private String getRealPathFromURI(Uri contentURI , Context context) {
String result;
Cursor cursor = context.getContentResolver().query(contentURI, null, null, null, null);
if (cursor == null) { // Source is Dropbox or other similar local file path
result = contentURI.getPath();
} else {
cursor.moveToFirst();
int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
result = cursor.getString(idx);
cursor.close();
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment