Home > Mobile >  can't find pdf document generated by my app using itext-7 only after restarting my android devi
can't find pdf document generated by my app using itext-7 only after restarting my android devi

Time:01-21

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();

CodePudding user response:

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.

  •  Tags:  
  • Related