Fileprovider "failed To Find Configured Root" Exception
Solution 1:
It seems I found workaround or fix.
Changing the root directory type I was using from external-files-path
to cache-path
in the xml and from context.getExternalFilesDir("export");
to File dir = new File(context.getCacheDir(), "export");
for getting the folder to create the file.
And I successfully attached the file. Note that in the FileProvider.java for the FileProvider class I found the following code for constructing the Uris:
if (TAG_ROOT_PATH.equals(tag)) {
target = buildPath(DEVICE_ROOT, path);
} elseif (TAG_FILES_PATH.equals(tag)) {
target = buildPath(context.getFilesDir(), path);
} elseif (TAG_CACHE_PATH.equals(tag)) {
target = buildPath(context.getCacheDir(), path);
} elseif (TAG_EXTERNAL.equals(tag)) {
target = buildPath(Environment.getExternalStorageDirectory(), path);
}
Which looks like only the following 4 folders are supported: TAG_ROOT_PATH, TAG_FILES_PATH, TAG_CACHE_PATH, TAG_EXTERNAL. There is no TAG_EXTERNAL_FILES or something like this, so this seems like a mismatch between the documentation and the implementation, and actually the external-files-path
matching the getExternalFilesDir
method is not supported.
Solution 2:
FilephotoFile=newFile(fullFileName);
if (photoFile != null) {
UriphotoURI=FileProvider.getUriForFile(MainActivity.this(your activity name),
BuildConfig.APPLICATION_ID + ".provider", photoFile);
}
if you create Uri like this may be it work for you.
Solution 3:
There is some workaound:
<?xml version="1.0" encoding="utf-8"?><pathsxmlns:android="http://schemas.android.com/apk/res/android"><files-pathname="logs"path="../logs/" /><!-- use ".." to get files from app's root data dir --></paths>
to provide files from /data/data/xxx.xxx.xxx/
in my case it was /data/data/xxx.xxx.xxx/logs/
Post a Comment for "Fileprovider "failed To Find Configured Root" Exception"