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
FileProvider: Failed to find configured root
The documentation for FileProvider
says that <files-path>
:
Represents files in the
files/
subdirectory of your app's internal storage area. This subdirectory is the same as the value returned byContext.getFilesDir()
.
Your file is not in internal storage. It is in external storage. For that, you need an <external-path>
element, not a <files-path>
element.
Android: FileProvider IllegalArgumentException Failed to find configured root that contains /data/data/**/files/Videos/final.mp4
You have your name
and your path
flipped. name
is what goes in the Uri
, and path
is the relative location within the root on the filesystem.
Go with:
<paths>
<files-path name="my_docs" path="Videos/" />
</paths>
FileProvider not working with Failed to find configured root that contains
<paths>
<external-files-path
name="my_docs"
path="docs" />
</paths>
When you specify path as docs
the sub-directories are not included. You get the exception because its not expecting to share the subdirectories. To include them append /
at the end as follows:
<paths>
<external-files-path name="my_docs" path="docs/" />
</paths>
Android: IllegalArgumentException: Failed to find configured root that contains /data/data/
In filepaths.xml
you need
<cache-path name="shared_images_from_glide_cache" path="image_manager_disk_cache"/>
This will result in mapping
new File("/data/data/com.example.glide02/cache/image_manager_disk_cache/5a992029460eed14244e8b970d969d45518b2f7ac10f71eb26bd0aaf7c3bcf06.0")
to
Uri.parse("content://com.example.glide02/shared_images_from_glide_cache/5a992029460eed14244e8b970d969d45518b2f7ac10f71eb26bd0aaf7c3bcf06.0")
(Not sure if I got it exactly right, but you should get the point.)
File Provider Exception : Failed to find configured root that contains
Replace:
path="Android/data/com.example.app/files"
with:
path="."
<external-files-path>
already points to the location that you are identifying in path
.
Android: FileProvider.getUriForFile Failed to find configured root
Replace path="Android/data/asmund.thomas.group_project/files/Pictures/"
with path="."
.
Related Topics
How to Programmatically Tell If a Bluetooth Device Is Connected
Difference Between Getdefaultsharedpreferences and Getsharedpreferences
How to Send String from One Activity to Another
Updating Google Play Services in Emulator
Android - How to Investigate an Anr
Telephonymanager.Getline1Number() Failing
Android Fragment Onclick Button Method
How to Fire Onlistitemclick in Listactivity with Buttons in List
How to Use Custom Font in a Project Written in Android Studio
How to Programmatically Add Views to Views
What Is Activity.Finish() Method Doing Exactly
How to Get Current Time from Internet in Android
Android Deprecated Apache Module (Httpclient, Httpresponse, etc.)
Nested Recycler View Height Doesn't Wrap Its Content