Convert MBTiles map or Open Street Map to OSMDroid Offline SQLite map format
Step-by-step guide
You can convert MBTiles map and Open Street Map to OSMDroid Offline SQLite map format. For the first step, if you want to convert from MBTiles file, you should convert it to Open Street Map local format with MBUtil first.
- (Optional) Convert MBTiles file(filename.mbtiles) to standard Open Street Map format with MBUtil.
Important: Once you convert MBtiles file to OSM format, you will lose all of the UTFGrid data and metadata(e.g. boundaries, min zoom level, max zoom level, etc.) inside of the MBTiles file.
# Python installation(requires easy_install)$ easy_install mbutil$ mb-util -hUsage: mb-util [options] input outputExamples:Export an mbtiles file to a directory of files:$ mb-util world.mbtiles tiles # tiles must not already existImport a directory of tiles into an mbtiles file:$ mb-util tiles world.mbtiles # mbtiles file must not already exist
Now you can see the usage of the MBUtil.
After you perform mb-util world.mbtiles tiles, you will get a standard Open Street Map folder called “tiles”, and the folder structure would be tiles/{zoom}/{x}/{y}.png. zoom means zoom level of the specified tile, and x y mean the tile position of the whole map, not coordinate. If you don’t know what is tile position and zoom level, please see the definition of the tile position below:

And also you can refer to:
Slippy map tilenames
OpenLayers Local Tiles Example
Convert OSM folder or the OSM data on the server to OSMDroid SQLite Map file, you will do it with OSMMapTilePackager, but OSMDroid doesn’t provide the binary file of OSMMapTilePackager, so you would compile it from the source code or download the binary file I compiled before: OSMMapTilePackager-5.6.4-SNAPSHOT.zip , please install JRE first.
Perform the command below, we will see the GUI of the OSMMapTilePackager, and we need to fill out boundaries, minimum zoom level and maximum zoom level, and Temp-Folder(tile source name, this is very important, you will use it when you load this map file in Android code).
$ ./OSMMapTilePackager -gui
this tool supports command line as well.
Tips: The extension name of the destination file must be “.sqlite”.
Congratulation! Now you can enjoy using your OSMDroid SQLite map file without any internet connections on Android.
Follow me at medium if you like this post ;-)
