Problems opening pdf in Android: Invalid file path

前端 未结 2 1752
遇见更好的自我
遇见更好的自我 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: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

提交回复
热议问题