title: How to copy a zip map file to /sdcard/osmdroid/ (internal storage)
body: <p>I created a map using MOBAC (Osmdroid zip format, OpenStreetMap MapQuest source).</p>
  <p>Now I have this ZIP file (the name of the file is prova.zip) in the assets folder of my Android project and I need to copy inside my phone (internal memory) to <code>/sdcard/osmdroid/</code>.
  I found some class around the web, but they do not work or maybe I do something wrong.</p>
  <p>How do I figure out this problem?</p>
  <h3>MainActivity.java</h3>
  <pre><code>public class MainActivity extends Activity {
      MyItemizedOverlay myItemizedOverlay = null;
      MyLocationOverlay myLocationOverlay = null;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          final MapView mapView = (MapView) findViewById(R.id.mapview);
          mapView.setTileSource(TileSourceFactory.MAPQUESTOSM);
          mapView.setBuiltInZoomControls(true);
          mapView.setMultiTouchControls(true);
  
          IMapController mapController = mapView.getController();
          mapController.setZoom(18);
  
          ScaleBarOverlay myScaleBarOverlay = new ScaleBarOverlay(this);
          mapView.getOverlays().add(myScaleBarOverlay);
  
          GeoPoint startPoint = new GeoPoint(0, 0);
  
          myLocationOverlay = new MyLocationOverlay(this, mapView);
          mapView.getOverlays().add(myLocationOverlay);
  
          myLocationOverlay.runOnFirstFix(new Runnable() {
              public void run() {
                  mapView.getController().animateTo(myLocationOverlay.getMyLocation());
              }
          });
      }
  
      @Override
      protected void onResume() {
          // TODO Auto-generated method stub
          super.onResume();
          myLocationOverlay.enableMyLocation();
          myLocationOverlay.enableCompass();
          myLocationOverlay.enableFollowLocation();
      }
  
      @Override
      protected void onPause() {
          // TODO Auto-generated method stub
          super.onPause();
          myLocationOverlay.disableMyLocation();
          myLocationOverlay.disableCompass();
          myLocationOverlay.disableFollowLocation();
      }
  }
  </code></pre>
  <p>I tried to implement this code, but it doesn't work:</p>
  <pre><code>private void copyAssets() {
      AssetManager assetManager = getAssets();
      String[] files = null;
  
      try {
          files = assetManager.list(&quot;&quot;);
      }
  
      catch (IOException e) {
          Log.e(&quot;tag&quot;, &quot;Failed to get asset file list.&quot;, e);
      }
  
      for(String prova : files) {
          InputStream in = null;
          OutputStream out = null;
  
          try {
              in = assetManager.open(prova);
              File outFile = new File(getExternalFilesDir(null) + &quot;/sdcard/osmdroid/&quot;, prova);
              out = new FileOutputStream(outFile);
              copyFile(in, out);
              in.close();
              in = null;
              out.flush();
              out.close();
              out = null;
          }
  
          catch(IOException e) {
              Log.e(&quot;tag&quot;, &quot;Failed to copy asset file: &quot; + prova, e);
          }
      }
   }
  
   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>