Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android FileProvider for CACHE DIR : Failed to find configured root that contains

I found so many links which is related to FileProvider, but I didn't found solution for cache directory

java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/pkg name/cache/1487876607264.png

I want to use it for CACHE DIRECTORY, How can I give path in provider.

<paths>
    <external-path name="external_files" path="."  />
</paths>

I used it as :

File file = new File(context.getCacheDir(), System.currentTimeMillis() + ".png");

Uri uri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", file);

Its working fine if I give application folder path, but not working with Cache Directory.

Any Help?

like image 954
Pratik Butani Avatar asked Feb 23 '17 19:02

Pratik Butani


1 Answers

Use <cache-path>, not <external-path>. See the documentation.

like image 76
CommonsWare Avatar answered Oct 14 '22 16:10

CommonsWare