Hello, I'm having a hard time messing with FileProvider.
The file gets created because I manually checked the directories. I put some logs to see what happens but even then I can not understand why it does not find
I generate a PDF but can not open it right away. Here is the code below.
AndroidManifest.xml
<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/filepaths" />
</provider>
filepaths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-files-path name="files" path="."/>
</paths>
creation of pdf file
File docsFolder = new File(Environment.getExternalStorageDirectory()+"/compras");
if (!docsFolder.exists()) {
docsFolder.mkdir();
Log.i(TAG, "Created a new directory for PDF");
}
comprovante = new File(docsFolder.getAbsolutePath(),"comprovante.pdf");
Attempt to load the file
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = FileProvider.getUriForFile(ComprasComprovanteActivity.this, BuildConfig.APPLICATION_ID + ".provider",comprovante);
The error
Failed to find configured root that contains /storage/emulated/0/compras/comprovante.pdf