How can i share a pdf file in android i am able to view the pdf using pdfView library from the abosolute path file so I think the path is correct but am not able to share using that same path that am using to view the pdf, i also try using toast to view the path which gives the correct path but when i try sharing the file the app crashes here is the code am using
Uri uri = Uri.fromFile(new File(arrayList.get(i).getAbsolutePath()));
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("application/pdf");
intent.putExtra(Intent.EXTRA_SUBJECT, "");
intent.putExtra(Intent.EXTRA_TEXT, "");
intent.putExtra(Intent.EXTRA_STREAM, uri);
try {
activity.startActivity(Intent.createChooser(intent, "Share Via"));
} catch (ActivityNotFoundException e) {
Toast.makeText(activity, "No Sharing App Found", Toast.LENGTH_SHORT).show();
}
``
So Here is the finally solution that worked
First this goes into the manifest just before the closing tag of your application
Then create an xml resources directory in your res folder then create the file you specified in your manifest that is provider_paths the past this inside the file
Then finally in your actual code do this