title: Write files to /system
body: <p>I know this has been asked a lot but never answered. I definetly need to write files to root there is no other solution. I currently use this code but it doesn't show anything new in /system/. I want to copy file from my assets to the /system folder (with it's subdir's)</p>
  
  <pre><code>public void installFiles(View v) {
              try {
          Runtime.getRuntime().exec("su");
      } catch (IOException e) {
          mDebugView.append(e.toString());
      }
      copyPath("system/bin", "/system/bin/");
      copyPath("system/lib", "/system/lib/");
      copyPath("system/etc", "/system/etc/");
      copyPath("system/etc/audio", "/system/etc/audio/");
      copyPath("system/etc/soundimage", "/system/etc/soundimage/");
      copyPath("system/lib/soundfx", "/system/bin/soundfx/");
  }
  
  public void copyPath(String from, String to) {
      mDebugView.append("Copying path assets/" + from + " to " + to + "\n");
      AssetManager assetManager = getAssets();
      String[] files = null;
      try {
          files = assetManager.list(from);
          for (String filename : files) {
              mDebugView.append(filename + "... \n");
              if (new File(filename).isFile()) {
                  mDebugView.append("Copying " + filename + "\n");
                  InputStream in = null;
                  OutputStream out = null;
                  in = assetManager.open(filename);
                  out = new FileOutputStream(to);
                  copyFile(in, out);
                  in.close();
                  in = null;
                  out.flush();
                  out.close();
                  out = null;
              }
          }
      } catch (IOException e) {
          Log.e(this.getClass().toString(), e.toString());
          mDebugView.append(e.toString() + "\n");
      }
  }
  
  private void copyFile(InputStream in, OutputStream out) throws IOException {
      mDebugView.append("..");
      byte[] buffer = new byte[1024];
      int read;
      while ((read = in.read(buffer)) != -1) {
          out.write(buffer, 0, read);
      }
  }
  </code></pre>