Kaloyan Roussev
Kaloyan Roussev

Reputation: 14711

FileProvider - use default InternalStorage folder, filePaths ambiguity

It says in the documentation:

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>

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

  1. This is an example file paths xml file from the documentation:

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

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

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

Should I add it? Is it possible that the documentation has a mistake in it, or have I made a mistake somewhere?

Upvotes: 3

Views: 1665

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007554

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

Leave off the path attribute.

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

I have no idea what is giving you this message. If it is an IDE, it is probably a bug in the IDE. Technically, we don't even need the namespace declaration, though my sample app has it as well.

Should I add it?

No. This sample app works fine without it.

Upvotes: 1

Related Questions