Android Fileprovider: IllegalArgumentException: Failed to find configured root that contains

前端 未结 2 569
无人及你
无人及你 2021-02-13 05:04

I have a question about the android FileProvider. I want to save a pdf document and open it with a default program. I don´t want to save it in external Storage.

After I´

相关标签:
2条回答
  • 2021-02-13 05:53

    I´ve got it. There were two different Problems

    1. The first Issue was answered by CodeDiving. I had to use the Authority from the provider-declaration for the getUriForFile call. Using an other class caused the NullPointerException.

    2. I´ve tried to get a file from filesDirectory, but in my file_path I declared only a path to cache Directory. I changed it to 'files-path' and it worked. This error caused the IllegalArgumentException.

    0 讨论(0)
  • 2021-02-13 06:06

    According to your FileProvider file(XML), the second parameter is com.example.myApp.myActivity. That is

    Uri uri = FileProvider.getUriForFile(getApplicationContext(),
                                         "com.example.myApp.myActivity", pdf);
    
    0 讨论(0)
提交回复
热议问题