4

in my application, I have pdf files. I want to save those pdf files into my database. I am using SQLite as my Backend. How can I format those pdf file into bytes.

praveen voggu
  • 47
  • 1
  • 1
  • 3
  • 1
    rather than storing files(pdf or image) into sqlite, store them in separate location on Memory and store their path into sqlite, it will improve your application performance, visit my [answer](http://stackoverflow.com/a/9141116/996493) – Lucifer Jun 25 '12 at 04:33
  • 1
    I would strongly recommend saving the .pdf files to local storage (e.g. your SD card), and just saving links to the files (e.g. name, path and any metadata) in SQLLite. IMHO... – paulsm4 Jun 25 '12 at 04:33
  • if i have more than 100 pdf files is it works? – praveen voggu Jun 25 '12 at 04:42

2 Answers2

6

You can simply read all the bytes of the pdf file and store them in the blob field of sqlite DB, but a better solution which is highly recommended is to store the files on the Internal Storage and in your DB just store the file's path. You have also to check if there is enough memory storage for you.

K_Anas
  • 31,226
  • 9
  • 68
  • 81
1
  1. Check for available space in your local Storage.
  2. Save the PDF(you can save it to your customized folder for better access
  3. fetch the path of PDF
  4. Store the path in SQLite