Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save serhiitereshchenko/cbf4f6bb9e4b683ef5ee276e24790dee to your computer and use it in GitHub Desktop.
Save serhiitereshchenko/cbf4f6bb9e4b683ef5ee276e24790dee to your computer and use it in GitHub Desktop.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == FILE_CODE && resultCode == Activity.RESULT_OK) {
if (BuildConfig.VERSION_CODE > Build.VERSION_CODES.KITKAT) {
Uri uri = data.getData();
pathEditText.setText(uri.toString());
} else {
Uri uri = DocumentFile.fromFile(new File(data.getData().getPath())).getUri();
pathEditText.setText(uri.toString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment