I'm getting exception
java.io.FileNotFoundException: /data/data/XX/files/permissions.xml: open failed: EACCES (Permission denied)
when trying to copy file from SD Card to app data location. My code is
File copy = new File((getActivity()
                       .getApplicationContext().getFileStreamPath("permissions.xml")
                        .getPath()));
if (!copy.exists()) {
  try {
    copy.getParentFile().mkdirs();
    copy.createNewFile();
  } catch (Exception err) {
    err.printStackTrace();
  }
}
copyFileUsingChannel(xmlFile, copy);
method copyFileUsingChannel is calling method copyFileUsingStream directly. I have both write and read permissions declared in manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="XX">
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <application
...
I have no idea why this exception is thrown. I'm creating file from app package. Should it be caused by extending non-app class? Thanks for any help.
EDIT: Interesting fact I realized: File is created but cannot write content into it
 
    