I need to share pdf files from my assets folder. The pdf file changes based on language.
Assets structure is like -
assets
folder
countryA
languageA
pdfA
languageB
pdfB
countryB
languageA
pdfA
languageC
pdfC
My Android manifest file -
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
When the following code runs
FileProvider.getUriForFile(getActivity(),
BuildConfig.APPLICATION_ID + ".provider",
new File("String file name"));
I am getting a java.lang.IllegalArgumentException: Failed to find configured root that contains
/file:/android_asset/folder/countryA/languageA/file.pdf
I believe it is because the path in the provider xml is not configured.
<?xml version="1.0" encoding="utf-8"?>
<paths>
<files-path name="my_file_name" path="."/>
</paths>
I have used files-path as the files are under assets folder. Since the files are nested how do i configure the provider path.
I have consulted the following links