按照如下即可
https://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed
另外,关于res/xml/file_paths.xml
的<paths>
下应当添加的标签,可看:
https://blog.csdn.net/u013553529/article/details/83900704
其中,我的图片的路径是:
Environment.getExternalStorageDirectory().getAbsolutePath() + "/data/image.jpg"
external-path
,
对应的路径是:
/storage/emulated/0/data/image.jpg
,
所以根据上文,应该使用<external-path name="随便起个名字" path="data" />
。
如果标签使用错误,可能会发生如下错误:
参考下文 https://stackoverflow.com/questions/42516126/fileprovider-illegalargumentexception-failed-to-find-configured-root 可知,一般原因就是标签用错了。