Java 如何修复android.os.FileUrieExposedException:file:///storage/emulated/0/Documents/SM.pdf 通过Intent.getData()在应用程序之外公开

Java 如何修复android.os.FileUrieExposedException:file:///storage/emulated/0/Documents/SM.pdf 通过Intent.getData()在应用程序之外公开,java,android,Java,Android,这是我的代码: private void createPdf() { File docsFolder = new File(Environment.getExternalStorageDirectory() + "/Documents"); File pdfFile = new File(docsFolder.getAbsolutePath(), "SM.pdf"); try { OutputStream output = new FileOutputS

这是我的代码:

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();
}
注销:

android.os.FileUrieExposedException:file:///storage/emulated/0/Documents/SM.pdf 通过
Intent.getData()


当添加@Vishal BhutTack屏幕截图用于活动并另存为pdf文件@ZunNot you时,我的意思是询问@Vishal BhutTack屏幕截图用于活动并另存为pdf文件@ZunNot you时,我的意思是询问@Vishal检查此链接..使用文件提供程序打开文件..检查此链接..使用文件提供程序打开文件。。
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); 

StrictMode.setVmPolicy(builder.build());