Androidpdfviewer: How to open PDF file from Phone (External or internal Storage )?

Created on 4 Jan 2019  路  4Comments  路  Source: barteksc/AndroidPdfViewer

Hi, I am a new user of AndroidPdfViewer and I am learning Android App Development. By using your library I am able to open the pdf file from the Asset folder and from URL.

Now I would like to open the PDF file from my Phone (either from internal storage or SD card). I have several pdf files in my phone and I would like to open them, i.e. I would like to make my app a general pdf viewer to open any pdf file from any folder of my storages.

Can you help me, please? I am using the 2.8.2 version. .fromFile() or .fromSource() would work, but I do not get any useful syntax of them.

Most helpful comment

Well I found it

File path = new File(Environment.getExternalStorageDirectory().getPath(), "new.pdf"); String u = "file:///" + path.getAbsolutePath(); pdfview.fromUri(Uri.parse(u)).load();

All 4 comments

I am looking for answer too . Did you get any answer?

Yeah I am sure where the file is in the system and the path is correct but it showing that file does not exist. I tried using both fromfiles and fromSource.

Well I found it

File path = new File(Environment.getExternalStorageDirectory().getPath(), "new.pdf"); String u = "file:///" + path.getAbsolutePath(); pdfview.fromUri(Uri.parse(u)).load();

@yashagrawal300 I had same problem, Thanks for your code, got solution.

Was this page helpful?
0 / 5 - 0 ratings