0

Why can't I refer to a PDF file in my Android device?

I have a folder named "templates" in the root folder, and I have a PDF file in that. I've tried to refer to the file via the following:

File file = new File("/templates/myPDFFile.pdf");

but when I try to print file.exists(), it always returns me false.

Just as further information, my file hierarchy is:

root
  -src
     -com.example.text
        -MyActivity.java
  -templates
     -MyPDFFile.pdf

and my code is stored in MyActivity.java.

How do I reference accurately to the PDF file?

Wakka02
  • 1,491
  • 4
  • 28
  • 44
  • 1
    You must put it in assets and get it from there like : http://stackoverflow.com/questions/6491210/how-to-open-a-pdf-stored-either-in-res-raw-or-assets-folder – Harish Godara Aug 01 '13 at 07:48
  • Nice reply, it did indeed lead me to the answer I wanted. Thank you, if you'd post this as an answer I'll accept it. – Wakka02 Aug 02 '13 at 03:29

1 Answers1

0

You must put it in assets and get it from there like : How to open a pdf stored either in res/raw or assets folder?

Community
  • 1
  • 1
Harish Godara
  • 2,388
  • 1
  • 14
  • 28