2018-07-18
生命不息,奋斗不止,万事起于忽微,量变引起质变 -------- Hongyang
1.注册一个provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.test.demo.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
2.编写resource xml file
3.name代表什么
而 name 属性用于给 path 属性所指定的子目录名称取一个别名。后续生成 content:// URI 时,会使用这个别名代替真实目录名。这样做的目的,很显然是为了提高安全性
4.path是什么意思
path 属性用于指定当前子元素所代表目录下需要共享的子目录名称。注意:path 属性值不能使用具体的独立文件名,只能是目录名。
意味着路径下的全部文件
5.在paths节点内部支持以下几个子节点,分别为:
1. 代表设备的根目录new File("/");
2. 代表context.getFilesDir()
3. 代表context.getCacheDir()
4. 代表Environment.getExternalStorageDirectory()
5.代表context.getExternalFilesDirs()
6.代表getExternalCacheDirs()
image