How to share files from any path using a FileProvider?

那年仲夏 提交于 2019-12-10 16:03:52

问题


My app allows the user to download some content and store it in the folder of his choice. I want to create a ContentProvider to share those files, but I don't know how to do that when the downloaded files are stored outside of the app default path.

I tried to decalre to following filePath:

<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path name="." path="/" />
</paths>

but it just try to match shared file path with the root of the app default folder. Is there a way share files from the SD card for example ? If so how can I do it ?


回答1:


Is there a way share files from the SD card for example ?

Use <external-path> instead of <files-path>. The documentation for FileProvider has a bug; <external-path> maps to Environment.getExternalStorageDirectory().



来源:https://stackoverflow.com/questions/30276888/how-to-share-files-from-any-path-using-a-fileprovider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!