title: opening offline tiles in Osmdroid
body: <p>i am trying to develop an offline map using osmdroid and trying to use the mbtiles created from mobile atlas creator but every-time i open the application it crashes. here is my main activity code. When i use the normal jpg file to load tiles, it works fine but its no use as i cannot bound the maps.</p>
  
  <pre><code>    package com.maptry.katgp;
  
      import java.io.File;
      import java.util.ArrayList;
  
      import org.osmdroid.DefaultResourceProxyImpl;
      import org.osmdroid.ResourceProxy;
      import org.osmdroid.api.IMapController;
      import org.osmdroid.tileprovider.IRegisterReceiver;
      import org.osmdroid.tileprovider.tilesource.XYTileSource;
      import org.osmdroid.util.BoundingBoxE6;
      import org.osmdroid.util.GeoPoint;
      import org.osmdroid.views.MapController;
      import org.osmdroid.views.MapView;
      import org.osmdroid.views.overlay.OverlayItem;
  
      import android.os.Bundle;
      import android.os.Environment;
      import android.app.Activity;
  
      public class MainActivity extends Activity implements IRegisterReceiver {
  // initializing the mapview
  MapView mapView;
  // private MapController mapController;
   // ArrayList&lt;OverlayItem&gt; anotherOverlayItemArray;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      // contents from the main
  
      setContentView(R.layout.activity_main);
  
      // connecting with the xml layout id
  
      mapView = (MapView) findViewById(R.id.mapView);
  
      // setting the default online tiles
      // mapnik not working so replaced by mapquest
  
      // for online use
      // mapView.setTileSource(TileSourceFactory.MAPQUESTOSM);
  
      //adding the offline tiles using mbtiles
  
       DefaultResourceProxyImpl resProxy;
          resProxy = new DefaultResourceProxyImpl(this.getApplicationContext());
  
  
  
          File file = new File(Environment.getExternalStorageDirectory(), "maptile.mbtiles");
  
          MBTileProvider provider = new MBTileProvider(this, file);
          BoundedMapView mapView = new BoundedMapView(this, resProxy, provider);
  
          double north = 27.749177;
          double east  =  85.382652;
          double south = 27.648864;
          double west  =  85.262489;
          BoundingBoxE6 bBox = new BoundingBoxE6(north, east, south, west);
  
          mapView.setScrollableAreaLimit(bBox);
  
      /*
       * // adding the offline tiles
       * 
       * mapView.setTileSource(new XYTileSource("MapQuest",
       * ResourceProxy.string.mapquest_osm, 13, 18, 256, ".jpg", new String[]
       * { "http://otile1.mqcdn.com/tiles/1.0.0/map/",
       * "http://otile2.mqcdn.com/tiles/1.0.0/map/",
       * "http://otile3.mqcdn.com/tiles/1.0.0/map/",
       * "http://otile4.mqcdn.com/tiles/1.0.0/map/" }));
       */
  
      // for zooming and multitouch controls
  
      mapView.setBuiltInZoomControls(true);
      mapView.setMultiTouchControls(true);
  
      mapView.setUseDataConnection(false);
       MapController controller = mapView.getController();
          controller.setZoom(12);
          controller.animateTo(new GeoPoint(27.7, 85.32));
  }
  </code></pre>
  
  <p>}</p>