1
I made an APP that monitors events, and finally generates a PDF report with the data of this event. But when creating the file, if the device is with Android Nougat, nothing is generated. I’ve tried to create a folder, save the file in folders that already exist, looked at Android Developer, and nothing worked. How can I solve this problem?
PS: In other versions 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;
    }
No code or error, it is not possible to say for sure, however the most likely problem is runtime permissions or permissions on file sharing.
– ramaral
Thank you very much, your comment reminds me to try to make the permission at runtime.
– Everson D. Ferreira