create an inner custom folder with Environment.getExternalStoragePublicDirectory()

Viewed 20

i am using this following code to save a created pdf inside my phone;

                        File file = new File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(),"/" +user.getInjurdManFirstName() +user.getInjuredManSecondName()+ "-" + user.getIdNumber()+".pdf");

         

                    try{
                        myPdfdocument.writeTo(new FileOutputStream(file));
                        showMessage("SUCCES!");
                    }catch (IOException e){
                        e.printStackTrace();
                        showMessage("NO SUCCES");
                    }

the code works good but it save me the pdf file in the download folder, i want it to save it like: DOWNLOADS/"custom folder/"name.pdf"

i tried to use Context and its doesnt work

0 Answers
Related