Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
279 views
in Technique[技术] by (71.8m points)

android - Best way to include pdfs in an app

I have to develop an app which is basically a pdf reader: it is composed by a list, each list element is a pdf file name, when user clicks on a list element the pdf is popped out, read by a pdf reader installed on the device.

Now, problem is that i'd like to include these pdfs in my app. Till now the only way I found is to set them as resource, but the problem is that each time I want to display one of them I'll have to copy it in a public folder and this obviously takes time...isn't there another way?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can add a ContentProvider to your app that streams the PDFs to the other process from the resource. For example, my StreamProvider extends Android's FileProvider to add support for serving files from raw resources or assets. The demo project, in particular, demonstrates serving a PDF from assets.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...