title: Osmdroid 5.6, offline MBTiles
body: <p>I'm trying to use MBtiles offline with osmdroid, </p>
  
  <p>I took code sample from here <a href="https://github.com/osmdroid/osmdroid/blob/master/OpenStreetMapViewer/src/main/java/org/osmdroid/samplefragments/tileproviders/SampleOfflineOnly.java" rel="nofollow noreferrer">https://github.com/osmdroid/osmdroid/blob/master/OpenStreetMapViewer/src/main/java/org/osmdroid/samplefragments/tileproviders/SampleOfflineOnly.java</a></p>
  
  <p>But always empty map shown, is there problem with my code?</p>
  
  <p>my code is:</p>
  
  <pre><code>public class OSMDroid extends AppCompatActivity {
  
  private MapView mapView;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_osmdroid);
  
      mapView = (MapView) findViewById(R.id.map);
  
  
      String name = "map.mbtiles";
      File f = new File(Environment.getExternalStorageDirectory() + "/osmdroid", name);
      if (f.exists()) {
          try {
  
              //ok found a file we support and have a driver for the format, for this demo, we'll just use the first one
  
              //create the offline tile provider, it will only do offline file archives
              //again using the first file
              OfflineTileProvider tileProvider = new OfflineTileProvider(new SimpleRegisterReceiver(this),
                      new File[]{f});
  
              //tell osmdroid to use that provider instead of the default rig which is (asserts, cache, files/archives, online
              mapView.setTileProvider(tileProvider);
  
              //this bit enables us to find out what tiles sources are available. note, that this action may take some time to run
              //and should be ran asynchronously. we've put it inline for simplicity
  
              String source = "";
              IArchiveFile[] archives = tileProvider.getArchives();
              if (archives.length &gt; 0) {
                  //cheating a bit here, get the first archive file and ask for the tile sources names it contains
                  Set&lt;String&gt; tileSources = archives[0].getTileSources();
                  //presumably, this would be a great place to tell your users which tiles sources are available
                  if (!tileSources.isEmpty()) {
                      //ok good, we found at least one tile source, create a basic file based tile source using that name
                      //and set it. If we don't set it, osmdroid will attempt to use the default source, which is "MAPNIK",
                      //which probably won't match your offline tile source, unless it's MAPNIK
                      source = tileSources.iterator().next();
                      mapView.setTileSource(FileBasedTileSource.getSource(source));
                  } else {
                      mapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
                  }
  
              } else {
                  mapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
              }
              mapView.setUseDataConnection(false);
              mapView.setBuiltInZoomControls(true);
              IMapController mapController = mapView.getController();
              mapController.setZoom(10);
              GeoPoint startPt = new GeoPoint(61.5797,51.5997);
              mapController.setCenter(startPt);
              mapView.invalidate();
              return;
          } catch (Exception ex) {
              ex.printStackTrace();
          }
  
      }
  }
  }
  </code></pre>
  
  <p>MBTilesFileArchive getTileSources always returns empty string, here is implementation:</p>
  
  <pre><code>public Set&lt;String&gt; getTileSources(){
      //the MBTiles spec doesn't store source information in it, so we can't return anything
      return Collections.EMPTY_SET;
  }
  </code></pre>