I have looked around and can't find an answer to what I hope is quite a simple thing to achieve this question seemed similar but has no replies! So the problem is this; I have my offline map tiles on the android device here:
/sdcard/application-name/uuid/tiles
and I have set the OSM cache like so:
File applicationDir = new File(Environment.getExternalStorageDirectory(), File.separator + "application-name" + File.separator + "uuid" + File.separator);
OpenStreetMapTileProviderConstants.setCachePath(applicationDir.getAbsolutePath());
I then set up the TileSource:
ITileSource tileSource = new XYTileSource ("tiles", 0, 18, 256, ".png", new String[]{});
and the TileProvider:
tileProvider = new MapTileProviderBasic(getActivity());
tileProvider.setTileSource(tileSource);
When I run my app, I get a succession of these:
Error downloading MapTile: /15/16000/9960
java.lang.IllegalArgumentException: n <= 0: 0
at java.util.Random.nextInt(Random.java:175)
at org.osmdroid.tileprovider.tilesource.OnlineTileSourceBase.getBaseUrl(OnlineTileSourceBase.java:33)
at org.osmdroid.tileprovider.tilesource.XYTileSource.getTileURLString(XYTileSource.java:19)
at org.osmdroid.tileprovider.modules.MapTileDownloader$TileLoader.loadTile(MapTileDownloader.java:171)
at org.osmdroid.tileprovider.modules.MapTileModuleProviderBase$TileLoader.run(MapTileModuleProviderBase.java:291)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Presumably because the local tiles aren't found and the MapTileProviderBasic ultimately falls to the MapTileDownloader and it barfs because there are no online tiles.
Any suggestions gratefully received! Thanks.
ITileSource tileSource = new XYTileSource ("tiles", 0, 18, 256, ".png", new String[]{});
tryITileSource tileSource = new XYTileSource ("tiles", 0, 18, 256, ".png", new String[]{"http://i.dont.care.org/"});