我正在Android Studio中创建PDF。它已在许多设备上成功运行,但在Xiomi和Vivio手机中,它无法创建目录并最终显示为
FileNotFoundException
例外。
我已经尝试过// baseDir = Environment.getExternalStorageDirectory()+“ / PDFFolder”;
String baseDir=
Environment.getExternalStorageDirectory().getAbsolutePath()+"/PDFFolder";
File file1 = new File(baseDir);
if (!file1.exists()) {
file1.mkdirs();
}
Document document = new Document();
File file = new File(file1, "Icomas.pdf");
> /*Here at this line file1 can't be create in some of the devices like
> Xiomi and Vivo Phones.*/
if (!file1.exists()) {
file1.mkdirs();
}