简体   繁体   中英

Loading the pdf within the application on Android with PdfRenderer - how to locate the file?

I would like to use PdfRenderer to display the myDoc.pdf within the application:

File file = new File("/sdcard/Download/myDoc.pdf");
PdfRenderer renderer 
= new PdfRenderer(ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY));
...

The problem is, I want to include the myDoc.pdf in the application rather then assuming it's under /sdcard/Download/ or on some website.

How can I include the myDoc.pdf in the application and how the path to it should looks like in the code ?

I use Android Studio and I assume the /res should be somehow associated with such files.

Hi friend you need to store your pdf file in assets folder.

Please check the stackoverflow question regarding this

Read a pdf file from assets folder

If you still have problem let me know

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