I am developing an android app using itext7 , I am not able to find the generated pdf files only after restarting my device
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString();
File file = new File(path , "attestation.pdf");
OutputStream outputStream = new FileOutputStream(file);
PdfWriter writer = new PdfWriter(file);
PdfDocument pdfDocument = new PdfDocument(writer);
Document document = new Document(pdfDocument);
Paragraph paragraph = new Paragraph("Hello world ! ");
document.add(paragraph);
document.close();
I think you have to update Media Library before other Apps can "see" it.
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(newMediaFile)));
Usually on restart Media Library is automatically updated, for this reason a simple reboot let other Apps to "see" this file.