0
Hello, I’m having a hard time with Fileprovider.
The file comes to be created because I checked manually in the directories. I put some logs to see what happens but still can not understand why he does not find
I send a PDF but I can’t open it right away. Below is the code.
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 upload the file
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = FileProvider.getUriForFile(ComprasComprovanteActivity.this, BuildConfig.APPLICATION_ID + ".provider",comprovante);
The mistake
Failed to find configured root that contains /storage/emulated/0/compras/comprovante.pdf
See if the way is this msm, does not seem error of permission, it seems that the way is wrong msm
– Woton Sampaio