FileProvider – IllegalArgumentException: Failed to find configured root

Your file is stored under getExternalFilesDir(). That maps to <external-files-path>, not <files-path>. Also, your file path does not contain images/ in it, so the path attribute in your XML is invalid.

Replace res/xml/file_paths.xml with:

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-files-path name="my_images" path="/" />
</paths>

UPDATE 2020 MAR 13

Provider path for a specific path as followings:

  • <files-path/> –> Context.getFilesDir()
  • <cache-path/> –> Context.getCacheDir()
  • <external-path/> –> Environment.getExternalStorageDirectory()
  • <external-files-path/> –> Context.getExternalFilesDir(String)
  • <external-cache-path/> –> Context.getExternalCacheDir()
  • <external-media-path/> –> Context.getExternalMediaDirs()

Ref: https://developer.android.com/reference/androidx/core/content/FileProvider

Leave a Comment

tech