I have been working to fetch file path from storage till now,
For example file path is /storage/emulated/0/Download/NTL_ANDRODI_DOGMA_SYSTEMS_SRL_A_SOCIO_UNICO_TEST NEW.afgclic
After android 11 it’s unable to fetch FilePath. After giving permission
uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
It’s allowing for Android 11 also, but app is getting rejected by Play store. Since the permission cannot be used without a specific reason and its allowed only for filemanager or antivirus app. Now the point is how other app manages to work on Android 11 for fetching files.
I have been using READ and WRITE storage permission to access file from external storage. Files are required to verify license from other library information.
5
Answers
I have fixed it by fetching path from Google drive
The android 11 introduced scoped storage to handle storage. Refer to https://developer.android.com/about/versions/11/privacy/storage for reference.
Its very difficult to answer your question.We need some information like what you do with files in your app.What is the usecase of filepath in your application.
If you really need file to be accessed via file path then you can copy the file to your apps private directory(not reasonable for working with large video or other files).
You can use contentResolver to open fileDescriptor to access the file.
You can open e folderSelector intent to let user select a folder where you can get full access to this folder using DocumentFile class.
Best way would be to replace your filepath dependency with uri(if possible).
learn more about scoped storage at Here
In
Android 11
you have to useScoped Storage
if you want full access of storage.If you want to access public directories like Documents, Download etc.You can use
legacyStorage
.In Your
Manifest
If you want to access full storage you can use
Scoped Storage
Add Permissions In Your
Manifest
Now just ask for Permission in your code
In android 11, there comes scoped storage feature to handle external storage.
for better residue file mgmnt and access mgmnt.
Here’s Philip Lackner’s playlist that I followed:
https://www.youtube.com/watch?v=TkOzcyzH1hU&list=PLQkwcJG4YTCR9jZq8O19nUL2hLqmLYX4M