Failed to find configured root that contains /file:/storage/emulated/0/Android/data

34 Views Asked by At

I am trying to share file downloaded by DownloadManager but FileProvider.getURIForFile returns exception Failed to find configured root that contains Failed to find configured root that contains /file:/storage/emulated/0/Android/data/com.siliconmind.reportsystem.debug/files/Download/2024_03_17_22_report.pdf

I tried the following code but it keeps throwing exception val uri = FileProvider.getUriForFile( requireContext(), context?.applicationContext?.packageName + ".fileprovider", File("file:///storage/emulated/0/Android/data/com.siliconmind.reportsystem.debug/files/Download/2024_03_17_22_report.pdf:) ) val intent = Intent(Intent.ACTION_SEND) intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) intent.setType("*/*") intent.putExtra(Intent.EXTRA_STREAM, uri) intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK) startActivity(intent)

This is the provider_paths file <paths> <external-files-path name="my_download" path="/"/> </paths>

And in manifest file <provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" /> </provider>

0

There are 0 best solutions below