【发布时间】:2019-11-06 23:00:58
【问题描述】:
这是我的代码:
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.FileUriExposedException: file:///storage/emulated/0/Documents/SM.pdf 通过
Intent.getData()暴露在应用之外
【问题讨论】:
-
使用文件提供程序打开文件..