title: Android/Java: I/System.out: Error :java.io.FileNotFoundException: /storage/emulated/0/heremaps/...: open failed: ENOENT (No such file or directory)
body: <p>I try to copy a folder from the assets to the external storage but I have the error messages:</p>
  <pre><code>I/System.out: Error :java.io.FileNotFoundException: /storage/emulated/0/heremaps/appcache/sat/12/CURRENT: open failed: ENOENT (No such file or directory)
  I/System.out: Error :java.io.FileNotFoundException: /storage/emulated/0/heremaps/appcache/sat/12/LOCK: open failed: ENOENT (No such file or directory)
  I/System.out: Error :java.io.FileNotFoundException: /storage/emulated/0/heremaps/appcache/sat/12/MANIFEST-000008: open failed: ENOENT (No such file or directory)
  I/System.out: Error :java.io.FileNotFoundException: /storage/emulated/0/heremaps/assets/here/miami/font/FiraGO-Map.LICENSE: open failed: ENOENT (No such file or directory)
  I/System.out: Error :java.io.FileNotFoundException: /storage/emulated/0/heremaps/assets/here/miami/font/FiraGO_Map.ttf: open failed: ENOENT (No such file or directory)
  I/System.out: Error :java.io.FileNotFoundException: /storage/emulated/0/heremaps/assets/here/miami/font/HanSans_ExtraLight.ttf: open failed: ENOENT (No such file or directory)
  I/System.out: Error :java.io.FileNotFoundException: /storage/emulated/0/heremaps/assets/here/miami/font/Lohit.LICENSE: open failed: ENOENT (No such file or directory)
  ...
  </code></pre>
  <p>Here is my code:</p>
  <pre><code> private void copyAsset(String path) {
          AssetManager manager = getAssets();
  
          // If we have a directory, we make it and recurse. If a file, we copy its
          // contents.
          try {
              String[] contents = manager.list(path);
  
              if (contents == null || contents.length == 0)
                  throw new IOException();
  
              // Création des dossiers
              String destination = Environment.getExternalStorageDirectory().getPath() + File.separator;
              File dir = new File( destination + path);
  
              dir.mkdirs();
  
              // Recurse on the contents.
              for (String entry : contents) {
                  copyAsset(path + &quot;/&quot; + entry);
              }
          } catch (IOException e) {
              copyFileAsset(path);
          }
      }
  
      private void copyFileAsset(String path) {
          // File file = new File(Environment.getExternalStorageDirectory().getPath() + &quot;/NTA/&quot; + path);
          String destination = Environment.getExternalStorageDirectory().getPath() + File.separator;
          File file = new File( destination + path);
  
          try {
              InputStream in = getAssets().open(path);
              OutputStream out = new FileOutputStream(file);
              byte[] buffer = new byte[1024];
              int read = in.read(buffer);
              while (read != -1) {
                  out.write(buffer, 0, read);
                  read = in.read(buffer);
              }
              out.close();
              in.close();
          } catch (IOException e) {
              System.out.println(&quot;Error :&quot; + e);
          }
      }
  </code></pre>
  <p>And my Androidmanifest:</p>
  <pre><code>   &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.WAKE_LOCK&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_WIFI_STATE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_BACKGROUND_LOCATION&quot; /&gt;
  
      &lt;application 
          android:requestLegacyExternalStorage=&quot;true&quot;
          android:name=&quot;.ApplicationClass&quot;
          android:allowBackup=&quot;true&quot;
  </code></pre>
  <p>Thanks</p>