How to open a PDF stored in Internal Memory

后端 未结 2 1642
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 17:02

I have an App that downloads a PDF file and stores it with MODE_PRIVATE (for security purposes) on the Internal Memory of the App:

FileOutputStream fos = get         


        
相关标签:
2条回答
  • 2021-01-18 17:38

    How can I open and display the downloaded PDF file?

    Create a ContentProvider to serve the PDF file, then use an ACTION_VIEW Intent with the Uri to your ContentProvider to open it in the user's chosen PDF viewer.

    This sample project demonstrates how to serve a PDF file from internal storage.

    0 讨论(0)
  • 2021-01-18 17:42

    To make a file from internal storage available to other apps the cleanest approach is to use a content provider. Luckily, Android comes with FileProvider – an implementation that might just serve your needs. You don't need to implement code (contrary to the approach of @CommonsWare), you just need to specifiy the provider in your manifest.

    0 讨论(0)
提交回复
热议问题