7

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);
keuleJ
  • 3,418
  • 4
  • 30
  • 51
jelic98
  • 723
  • 1
  • 12
  • 28

2 Answers2

6

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

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I get "Unable to open content" when I try to play video from that directory, but if I define File on Environment.getExternalStorageDirectory() before MediaStore.ACTION_VIDEO_CAPTURE, video plays fine. Can you spot the problem? My app structure is: film a video using system intent and play it in VideoView. – jelic98 May 04 '17 at 19:57
  • @jelic98: Please provide a [mcve] demonstrating how you are using `FileProvider`. Specifically, are you adding `FLAG_GRANT_READ_URI_PERMISSION` to the `Intent`? – CommonsWare May 04 '17 at 20:08
  • I have managed to find the problem why VideoView is not playing desired video. Here is the new question: https://pastebin.com/uE72Jqd2 . Thanks for your help! – jelic98 May 04 '17 at 20:33
  • where is the XML ? – Ivan Apr 16 '21 at 09:01
  • @Ivan: The XML is in the question. – CommonsWare Apr 16 '21 at 11:36
0

XML should be:

 <files-path
        name="avatar_image"
        path="camera" />

More info here

Ivan
  • 6,388
  • 3
  • 24
  • 30