Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get the permisson for "Documents" directory on Android 10 #90

Closed
CXStudioTeam opened this issue May 20, 2022 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@CXStudioTeam
Copy link

Can't get the permisson using storage.requestStorageAccess() for Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).

**override fun onRootPathPermissionGranted(requestCode: Int, root: DocumentFile) {

}**

The above callback, get path from root is /storage/home , uri : content://com.android.externalstorage.documents/tree/home%3A/document/home%3A. Obviously it was wrong.

The reuslt On Andorid 11
path: /storage/emulated/0/Documents
uri: content://com.android.externalstorage.documents/tree/primary%3ADocuments/document/primary%3ADocuments

The result on Android 11 was right.

@anggrayudi anggrayudi added the enhancement New feature or request label Jul 11, 2022
@anggrayudi
Copy link
Owner

This is not a bug. Android 10 and lower OS versions treat Documents folder like Download. You can compare their URIs:

  • Download folder => content://com.android.providers.downloads.documents/tree/downloads
  • Documents folder => content://com.android.externalstorage.documents/tree/home%3A

They both use URI to manage files. On SimpleStorage v1.3.0 and lower, you may notice that function DocumentFile.getAbsolutePath() for Documents folder returns /storage/home. I have added the compatibility for Documents folder. Now DocumentFile.getAbsolutePath() will return /storage/emulated/0/Documents whenever the URI is content://com.android.externalstorage.documents/tree/home%3A

You can use Documents folder with this home URI to manage files after SimpleStorage v1.4.0, which will be released soon. I have tested it and worked on OS 10:

Screen Shot 2022-07-11 at 23 36 12

@anggrayudi
Copy link
Owner

Version 1.4.0 has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants