android - FileProvider - 使用默认的内部存储文件夹,文件路径不明确

标签 android

文档中说:

A FileProvider can only generate a content URI for files in directories that you specify beforehand. To specify a directory, specify the its storage area and path in XML, using child elements of the element. For example, the following paths element tells FileProvider that you intend to request content URIs for the images/ subdirectory of your private file area.

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

如果我不想使用子目录,而是使用默认的内部存储目录怎么办?

  1. 这是来自文档的示例文件路径 xml 文件:

    < 路径 xmlns:android="http://schemas.android.com/apk/res/android">

    <files-path name="my_images" path="images/"/>
    
    <files-path name="my_docs" path="docs/"/>
    

当我在我的项目中使用它时,我得到“属性缺少 Android 命名空间前缀”

我应该添加它吗?文档是否有可能有错误,或者我在某处犯了错误?

最佳答案

What If I dont want to use a subdirectory, but the default internalstorage directory?

离开 path 属性。

When I use it in my project, I get "Attribute is missing the Android namespace prefix"

我不知道是什么给了你这条信息。如果是IDE,那很可能是IDE的bug。从技术上讲,我们甚至不需要命名空间声明,尽管 my sample app也有。

Should I add it?

没有。 This sample app没有它也能正常工作。

关于android - FileProvider - 使用默认的内部存储文件夹,文件路径不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30892124/

相关文章:

java - java String.format 可以处理替换吗?而不是 %s

安卓 : Multiple resolution

android - R.Java 未生成

java - 同一级别的 If 语句如何同时在 Android/Java 程序中执行?

实现 PDF 查看器的 Android 代码

android - 使用 Google Places Autocomplete API 时空间不起作用

android - 多个android应用程序可以访问同一个firebase数据库吗?

java - 需要更快的 Word Builder 算法

android - Mobiscroll 的问题 - orientationchange 和 access address bar 会导致一些移动浏览器崩溃

Android uber 错误 No authentication challenges found