Home > database >  Android 11 not fetching path for file
Android 11 not fetching path for file

Time:01-24

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 its unable to fetch FilePath. After giving permission

uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"

Its 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

Waiting to get the issue resolved. Thanks for the help.

CodePudding user response:

The android 11 introduced scoped storage to handle storage. Refer to https://developer.android.com/about/versions/11/privacy/storage for reference.

CodePudding user response:

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

  •  Tags:  
  • Related