title: copy folder containing 10 mp3 files from Assets to SD-card
body: <p>I'm developing an android free drum kit app for <code>Electrum Drum Machine/Sampler</code>.</p>
  
  <p>I need to copy a folder containing <code>10-20</code> mp3 files from Assets to <code>SD-card</code>.
  I need the folder containing the files to go here "sdcard/electrum"
  also where exactly do I insert the path  "sdcard/electrum"  in the code!</p>
  
  <p>I'm new to coding but catching on real fast I can code my UI's, button, pages, but I just need a little help thank you!</p>
  
  <p>here is my code...</p>
  
  <pre><code>package com.example.newsampletest;
  
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  
  import android.app.Activity;
  import android.content.res.AssetManager;
  import android.os.Bundle;
  import android.util.Log;
  
  public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          copyAssets();
  
      }
  
      private void copyAssets() {
          AssetManager assetManager = getAssets();
          String[] files = null;
          try {
              files = assetManager.list("files");
          } catch (IOException e) {
  
          }
          for(String filename : files) {
              InputStream in = null;
              OutputStream out = null;
              try {
                  in = assetManager.open(filename);
                  out = new FileOutputStream("files/"+filename);
                  copyFile(in, out);
                  in.close();
                  in = null;
                  out.flush();
                  out.close();
                  out = null;
              } catch(Exception e) {
                  Log.e("tag", e.getMessage());
              }
          }
      }
  
      private void copyFile(InputStream in, OutputStream out) throws IOException {
          byte[] buffer = new byte[1024];
          int read;
          while((read = in.read(buffer)) != -1){
              out.write(buffer, 0, read);
          }
      }
  }
  </code></pre>