I did an APP that does the event monitoring, and finally, it generates a PDF report with the data of that event. But at the time of creating the file, if the device is running Android Nougat, nothing is generated. I have already tried to create a folder, save the file to folders that already exist, I looked at Android Developer, and nothing worked. How can I resolve this problem?
PS: In other versions it works normally.
try {
filename = "CCB - Dados Reunião.pdf";
document = new Document(PageSize.A4);
path = Environment.getExternalStorageDirectory() + "/DADOS CCB";
//path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + "/CCB";
File dir = new File(path, filename);
if (!dir.exists()) {
dir.getParentFile().mkdirs();
}
FileOutputStream fOut = new FileOutputStream(dir);
fOut.flush();
PdfWriter.getInstance(document, fOut);
document.open();} catch (DocumentException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
document.close();
return true;
}