title: Write files to the Android external storage using React Native FS
body: <p>My React Native Android application needs to save a JSON file in the special folder located in the external storage. I am trying to do it using RNFS (<a href="https://github.com/itinance/react-native-fs" rel="noreferrer">https://github.com/itinance/react-native-fs</a>) this way:</p>
  <pre><code>const saveData = async () =&gt; {
      var path = `${RNFS.ExternalStorageDirectoryPath}/MyApp`;
      RNFS.mkdir(path);
      path += '/data.json';
      RNFS.writeFile(path, JSON.stringify(getData()), 'utf8')
        .then((success) =&gt; {
          console.log('Success');
        })
        .catch((err) =&gt; {
          console.log(err.message);
        });
    }
  </code></pre>
  <p>It works well but fails on Android Q device. This error is shown:</p>
  <p><code>Error: Directory could not be created</code></p>
  <p>If I try to write a plain file without creating directory it throws this error:</p>
  <p><code>ENOENT: open failed: ENOENT (No such file or directory), open '/storage/emulated/0/data.json'</code></p>
  <p>However, I've added this permissions to my <code>AndroidManifest.xml</code>:</p>
  <pre><code>&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;/&gt;
  </code></pre>
  <p>And granted the external storage permissions in the settings. But if I change the <code>RNFS.ExternalStorageDirectoryPath</code> to <code>RNFS.DocumentDirectoryPath</code> it works without any errors. But I need to get an access to the external storage. Is there any way to do it?</p>