简体   繁体   中英

Why pdf not generate Android Q?

Why this not generate the pdf from android version10(Q) but android version 8 also generate the pdf please help me....

enter code here File file=new File(Environment.getExternalStorageDirectory().getPath()+"/SAMPLE.pdf");

            try{
            mypdfDocument.writeTo(new FileOutputStream(file));

            }catch (IOException e){
            e.printStackTrace();
            }
            mypdfDocument.close();
            }

You will have to add android:requestLegacyExternalStorage="true" to your manifest, otherwise Android 10 will not allow access. In general, avoid directly accessing storage since it has become much more tricky from Android 11 onwards.

Also,

Environment.getExternalStorageDirectory().getPath()

will no longer return your desired path but will actually return the same path as

getFilesDir() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM