Reputation: 31
In this other question
How to use the new SD card access API presented for Android 5.0 (Lollipop)?
It is explained how to use the new API to access the "external SDCard".
But, how can I know the actual directory returned in the result activity?
I mean in function
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
if (resultCode == RESULT_OK) {
Uri treeUri = resultData.getData();
DocumentFile pickedDir = DocumentFile.fromTreeUri(this, treeUri);
......
How can I get the actual path where "Uri treeUri" points?
Thanks, Francis.
Upvotes: 3
Views: 652
Reputation: 304
Use
FileUtil.getFullPathFromTreeUri(treeUri, this)
from
to get the full path. Seperate the path using
final String[] seperated = treeUri.toString().split("\\/");
to get the current dir name.
Upvotes: 0
Reputation: 1669
You can't get the absolute path because the Documents API is designed to abstract this from you.
However, the treeUri
does contain the relative path to the file. Try examining the Uri using Uri#getPathSegments()
Upvotes: 0