I use the intent filter to get the path of the file selected by the user with a file-chooser, unfortunately I have problem to obtain the absolute path,
the path onActivityResult starts always with various extra data that cause errors in my app
for example
/content/:/myabsolutepath
or
file:///myabsolutepath
and the extra attributes depends on file type, file manager on the phone etc.
I need to get only the absolute path in the form
/myabsolutepath
Here there is my code
private void openFile() {
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.setType("file/*");
startActivityForResult(i, FILE_REQ_CODE);
}
protected void onActivityResult(int requestCode, int resultCode, Intent i) {
//String with the path;
path = i.getDataString();
super.onActivityResult(requestCode, resultCode, i);
}
Try:
path = i.getData().getPath();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With