0

I'm trying to save this PDf file in external storage but it only works for android 9 and below since something was removed for Android 10+. How can i save the file for android 10+.Kinda new with app dev so didn't understand the documentation.

                myPdfDocument.finishPage(myPage1);

                File file = new File(Environment.getExternalStorageDirectory(),"Client.pdf");

                try {
                    myPdfDocument.writeTo(new FileOutputStream(file));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                finally {
                    Snackbar.make(view, "PDF Created at" + Environment.getExternalStorageDirectory()+"Client.pdf", Snackbar.LENGTH_LONG)
                            .setAction("Action", null).show();
                }
                myPdfDocument.close();

1 Answers1

0
android:requestLegacyExternalStorage="true"

add this in your manifest under application tag.

WRITE_EXTERNAL_STORAGE when targeting Android 10

also read this

Shashank
  • 121
  • 6