Problems opening pdf in Android: Invalid file path

前端 未结 2 1755
遇见更好的自我
遇见更好的自我 2021-01-25 12:39

i need to open a pdf file from my android app. I have the pdf saved in the app package folder (/data/data/com.app.example/files). I have installed in the android emulator the ad

相关标签:
2条回答
  • 2021-01-25 13:01

    This is because the PDF file resides in your own package and Adobe reader trying to access PDF file from your package which is not allowed for Android application development.

    You can try to save file on SDCARD and then open it

    0 讨论(0)
  • 2021-01-25 13:17

    Don't use the direct path to access files in application's private to your application. Instead use

    FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
    

    Refer: http://developer.android.com/guide/topics/data/data-storage.html#filesInternal

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