0

I am building an app for viewing pdf file. I could build MuPDF library.

I want my app to open only pdf files which I will keep in /assets folder. Source code supplied comes with code which reads file from SD card. I want to read and display files supplied with app (either in /assets or /raw folder whichever is viable)

I am new to NDK. Please guide me.

Avinash Sahu
  • 249
  • 3
  • 19

1 Answers1

2

The files in assets are not stored as individual files on the device. The APK is a compressed ZIP file; the assets folder only exists there.

Copy the file from assets on the apps' first run (see e. g. here for an example).

EDIT: If the only way MuPDF takes files is by file name, you're out of luck. It doesn't have to be SD card - you can use your app's internal storage folder (use Context.getDir() to get one). If it can take an in-memory data block, you can read the file on the caller side by means of AAssetManager (or in Java) and pass the data to the library.

Maybe Android has an in-memory temp filesystem that you could leverage; I'm not sure.

Community
  • 1
  • 1
Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
  • Thanks Seva. I will try this. What if I don't want my data to be copied into SD card and want my app to open files supplied with my app only. – Avinash Sahu Sep 30 '13 at 17:54