0

Let's say I have this content uri

content:///com.test.mypackage/provider_path

I'm using FileProvider for this content uri and was constructed using

Uri photoUri = FileProvider.getUriForFile(MainActivity.this, "com.test", image);

since I'm using FileProvider I need to specify a path in an xml resource;

<external-path name="external_files" path="Folder1/"/>

From the generated content uri specified above, does the directory structure for this is:

com.test.mypackage > Folder1

I don't know if the content uri points out to a directory. Btw I'm trying to save an image to a directory using FileProvider.

zbryan
  • 805
  • 2
  • 12
  • 24

1 Answers1

0

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.

Then, the files you are specifying in XML as

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

are in your app's private file area, in this particular case the file myfile will be in the subdirectory mydir under the directory getFilesDir() points to.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134