title: Rendering speed is very slow when i use offline map data in osmdroid MapView
body: <p>My offline map data source format is MBTiles . The database got 2 tables:
  Table1 name is preferences which stored the data like: 
  name,value</p>
  
  <p>Table2 name is tiles which store the data like:</p>
  
  <p>tileKey,zoom,row,col,image</p>
  
  <p>Then i create a class </p>
  
  <p>public class MBTileSource extends BitmapTileSourceBase {</p>
  
  <pre><code>// Log log log log ...
  private static final Logger logger = LoggerFactory
          .getLogger(MBTileSource.class);
  
  // Database related fields
  public final static String TABLE_TILES = "tiles";
  public final static String COL_TILES_ZOOM_LEVEL = "zoom";
  public final static String COL_TILES_TILE_COLUMN = "col";
  public final static String COL_TILES_TILE_ROW = "row";
  public final static String COL_TILES_TILE_DATA = "image";
  
  protected SQLiteDatabase database;
  protected File archive;
  
  // Reasonable defaults ..
  public static final int minZoom = 8;
  public static final int maxZoom = 15;
  public static final int tileSizePixels = 256;
  
  // Required for the superclass
  public static final string resourceId = ResourceProxy.string.offline_mode;
  
  /**
   * The reason this constructor is protected is because all parameters,
   * except file should be determined from the archive file. Therefore a
   * factory method is necessary.
   * 
   * @param minZoom
   * @param maxZoom
   * @param tileSizePixels
   * @param file
   */
  protected MBTileSource(int minZoom, int maxZoom, int tileSizePixels,
          File file, SQLiteDatabase db) {
      super("sqlite", resourceId, minZoom, maxZoom, tileSizePixels, ".png");
  
      archive = file;
      database = db;
  }
  
  /**
   * Creates a new MBTileSource from file.
   * 
   * Parameters minZoom, maxZoom en tileSizePixels are obtained from the
   * database. If they cannot be obtained from the DB, the default values as
   * defined by this class are used.
   * 
   * @param file
   * @return
   */
  public static MBTileSource createFromFile(File file) {
      SQLiteDatabase db;
      int flags = SQLiteDatabase.NO_LOCALIZED_COLLATORS
              | SQLiteDatabase.OPEN_READONLY;
  
      // int value;
      int minZoomLevel=minZoom;
      int maxZoomLevel=maxZoom;
      int tileSize = tileSizePixels;
      InputStream is = null;
  
      // Open the database
      db = SQLiteDatabase.openDatabase(file.getAbsolutePath(), null, flags);
  
      // Get the minimum zoomlevel from the MBTiles file
      Cursor pCursor = db.rawQuery("SELECT * FROM preferences;", null);
      try {
          if (pCursor.getCount() != 0) {
              pCursor.moveToFirst();
              do {
                  String name=pCursor.getString(pCursor.getColumnIndex("name"));
                  if(name.equalsIgnoreCase("map.minZoom")){
                      minZoomLevel=pCursor.getInt(pCursor.getColumnIndex("value"));
                  }else if(name.equalsIgnoreCase("map.maxZoom")){
                      maxZoomLevel=pCursor.getInt(pCursor.getColumnIndex("value"));
                  }else if(name.equalsIgnoreCase("map.tileSideLength")){
                      tileSize=pCursor.getInt(pCursor.getColumnIndex("value"));
                  }
              } while (pCursor.moveToNext());
          }
          pCursor.close();
      } catch (Exception e) {
          // TODO: handle exception
      }
  
      return new MBTileSource(minZoomLevel, maxZoomLevel, tileSize, file, db);
  }
  
  public InputStream getInputStream(MapTile pTile) {
  
      try {
          InputStream ret = null;
          final String[] tile = { COL_TILES_TILE_DATA };
          final String[] xyz = {
                  Integer.toString(pTile.getX()),
                  Double.toString(Math.pow(2, pTile.getZoomLevel())
                          - pTile.getY() - 1),
                  Integer.toString(pTile.getZoomLevel()) };
  
          final Cursor cur = database.query(TABLE_TILES, tile,
                  "col=? and row=? and zoom=?", xyz, null,
                  null, null);
  
          if (cur.getCount() != 0) {
              cur.moveToFirst();
              ret = new ByteArrayInputStream(cur.getBlob(0));
          }
  
          cur.close();
  
          if (ret != null) {
              return ret;
          }
  
      } catch (final Throwable e) {
          logger.warn("Error getting db stream: " + pTile, e);
      }
  
      return null;
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>it work well to show the off line map. Only one problem is : The rendering speed is really slow</p>
  
  <p>any suggestion?
  thanks.</p>