Can I create a DocumentFile with a stored Uri?

Multi tool use
up vote
0
down vote
favorite
I got a Uri using the following method.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, MY_REQUEST_CODE);
like:
content://com.android.externalstorage.documents/tree/primary%3A
Can I store this string to create a DocumentFile in application startup?
like:
DocumentFile.fromUri(this,Uri.pasre(str))
It works on Android 6.0,but it seems invalid in higher version.
Or I should get Uri every time I start it?
I have found that some file managers do not need to get Uri via startActivityForResult(). Like RE. Are they using the shell to get a list under /storage and then stitching them into Uri?
Then use grantUriPermission() and takePersistableUriPermission() to get Uri permissions?
Sorry, my English is too bad. TT

New contributor
nolizemin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
favorite
I got a Uri using the following method.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, MY_REQUEST_CODE);
like:
content://com.android.externalstorage.documents/tree/primary%3A
Can I store this string to create a DocumentFile in application startup?
like:
DocumentFile.fromUri(this,Uri.pasre(str))
It works on Android 6.0,but it seems invalid in higher version.
Or I should get Uri every time I start it?
I have found that some file managers do not need to get Uri via startActivityForResult(). Like RE. Are they using the shell to get a list under /storage and then stitching them into Uri?
Then use grantUriPermission() and takePersistableUriPermission() to get Uri permissions?
Sorry, my English is too bad. TT

New contributor
nolizemin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I got a Uri using the following method.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, MY_REQUEST_CODE);
like:
content://com.android.externalstorage.documents/tree/primary%3A
Can I store this string to create a DocumentFile in application startup?
like:
DocumentFile.fromUri(this,Uri.pasre(str))
It works on Android 6.0,but it seems invalid in higher version.
Or I should get Uri every time I start it?
I have found that some file managers do not need to get Uri via startActivityForResult(). Like RE. Are they using the shell to get a list under /storage and then stitching them into Uri?
Then use grantUriPermission() and takePersistableUriPermission() to get Uri permissions?
Sorry, my English is too bad. TT

New contributor
nolizemin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I got a Uri using the following method.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, MY_REQUEST_CODE);
like:
content://com.android.externalstorage.documents/tree/primary%3A
Can I store this string to create a DocumentFile in application startup?
like:
DocumentFile.fromUri(this,Uri.pasre(str))
It works on Android 6.0,but it seems invalid in higher version.
Or I should get Uri every time I start it?
I have found that some file managers do not need to get Uri via startActivityForResult(). Like RE. Are they using the shell to get a list under /storage and then stitching them into Uri?
Then use grantUriPermission() and takePersistableUriPermission() to get Uri permissions?
Sorry, my English is too bad. TT


New contributor
nolizemin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
nolizemin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Nov 7 at 7:07
New contributor
nolizemin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Nov 7 at 6:21


nolizemin
11
11
New contributor
nolizemin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
nolizemin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
nolizemin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
nolizemin is a new contributor. Be nice, and check out our Code of Conduct.
nolizemin is a new contributor. Be nice, and check out our Code of Conduct.
nolizemin is a new contributor. Be nice, and check out our Code of Conduct.
nolizemin is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53184466%2fcan-i-create-a-documentfile-with-a-stored-uri%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
jVoHxPmeS1E5,AscM8W9 Tdm b43Z,75,C3F1,zar7m3A jc0KveAc