Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileProvider from getFilesDir()

What is the corresponding XML for Context.getFilesDir()?

My current XML:

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

File creation:

File video = new File(getFilesDir(), "movie.mp4");
videoUri = FileProvider.getUriForFile(this, "my.package.name.provider", video);
like image 672
jelic98 Avatar asked May 04 '17 19:05

jelic98


People also ask

How do I use FileProvider?

To make FileProvider work follow these three steps: Define the FileProvider in your AndroidManifest file. Create an XML file that contains all paths that the FileProvider will share with other applications. Bundle a valid URI in the Intent and activate it.

What is FileProvider?

FileProvider is a special subclass of ContentProvider that facilitates secure sharing of files associated with an app by creating a content:// Uri for a file instead of a file:/// Uri . A content URI allows you to grant read and write access using temporary access permissions.


1 Answers

That is the XML for serving files from getFilesDir() through FileProvider.

like image 102
CommonsWare Avatar answered Sep 28 '22 23:09

CommonsWare