I am making project for my school. In this app, I am downloading pdf files from Firebase and storing it on app's external dir. After downloading, I want to through implicit intent to other pdf reader app to display downloaded pdf. I searched web for 2 days straight for how to create content provider but all tutorial are old and used android.support.v4 content provider and I don't know how to create custom content provider. I tried using androidx.core.content.fileprovider and it also created content uri but when launched, pdf reader screen pops but nothing is displayed, just title of file is displayed.
output of fileUri.toString- content://com.syrous.studentlibraryjava.fileprovider/document/mse1_dagaeg.pdf
Uri fileUri = getUriForFile(getApplicationContext(), getPackageName()+".fileprovider", localFile); //This is the in build function, just accepted import.
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(fileUri, "application/pdf");
i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
Here is the declaration of provider in manifest---->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.syrous.yccestudentlibraryjava.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"/>
</provider>
Here is the file_paths ----->
<paths>
<external-files-path
name="document"
path="mse1/"/>
</paths>
I'm not sure, if i declared file_path correct. I have my pdf file inside external_folder/files/mse1/file_to_open. If there is any correction in file_path, Please suggest me.
I have permission to read and write external storage declared in manifest and also asked for it
Help me guys!! Emulator Image