问题
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