This is my code:
private void createPdf() {
File docsFolder = new File(Environment.getExternalStorageDirectory() + "/Documents");
File pdfFile = new File(docsFolder.getAbsolutePath(), "SM.pdf");
try {
OutputStream output = new FileOutputStream(pdfFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
document.writeTo(new FileOutputStream(pdfFile));enter code here
} catch (IOException e) {
e.printStackTrace();
}
// close the document
document.close();
Toast.makeText(this, "PDF is created!!!", Toast.LENGTH_SHORT).show()
// openGeneratedPDF();
}
logout:
android.os.FileUriExposedException: file:///storage/emulated/0/Documents/SM.pdf exposed beyond app through
Intent.getData()