etamar211
etamar211

Reputation: 53

Where to save PDF files to open with external App

I need to crate an app that opens selected PDF files via external app.

I've tried putting all the files in the assets folder, but I didn't find a way to create a file-provider that will read from the assets folder. I prefer a solution that doesn't need copying files (so it won't take double memory). where should i put the Pdf files (in the developing stage)? is there a way to copy them to internal/external storage in the installing phase (so they won't be in the assets folder)? what should I do?

Upvotes: 1

Views: 65

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006869

I didn't find a way to create a file-provider that will read from the assets folder

My StreamProvider does that.

is there a way to copy them to internal/external storage in the installing phase (so they won't be in the assets folder)?

No. First, no ordinary files are copied out of the APK into files on the filesystem. Second, the APK itself is not modified at install time — doing so would invalidate the digital signature.

what should I do?

Option #1: Do not package the PDF with your app. Instead, download it.

Option #2: Do not use a PDF, but instead use HTML/CSS/JS, and render the assets using WebView

Option #3: Use my StreamProvider

Option #4: Create your own ContentProvider that can serve directly from assets (this sample app is crude but illustrates the technique)

Option #5: Do not worry about the disk space, copy the asset to a file on internal storage (e.g., getCacheDir()), and use FileProvider

Upvotes: 1

Related Questions