See: https://github.com/osmdroid/osmdroid/issues/78
This is the same issue (OSMDROID_PATH and TILE_PATH_BASE hardcoded and final).
Using this patch (potentially old version below), you could change the tile cache path as needed.
package org.osmdroid.tileprovider.constants;
import java.io.File;
import android.os.Environment;
/**
* This class contains key settings related to the osmdroid cache, and methods to change default values.
*/
public class TilesCacheSettings {
/** Base path for osmdroid files. Zip files are in this folder. */
public static File OSMDROID_PATH = new File(Environment.getExternalStorageDirectory(),
"osmdroid");
/** Base path for tiles. */
public static File TILE_PATH_BASE = new File(OSMDROID_PATH, "tiles");
/** 600 Mb */
public static long TILE_MAX_CACHE_SIZE_BYTES = 600L * 1024 * 1024;
/** 500 Mb */
public static long TILE_TRIM_CACHE_SIZE_BYTES = 500L * 1024 * 1024;
/** Change the root path of the osmdroid cache.
* By default, it is defined in SD card, osmdroid directory.
* @param newFullPath
*/
public static void setCachePath(String newFullPath){
OSMDROID_PATH = new File(newFullPath);
TILE_PATH_BASE = new File(OSMDROID_PATH, "tiles");
}
/** Change the osmdroid tiles cache sizes
* @param maxCacheSize in Mb. Default is 600 Mb.
* @param trimCacheSize When the cache size exceeds maxCacheSize, tiles will be automatically removed to reach this target. In Mb. Default is 500 Mb.
*/
public static void setCacheSizes(long maxCacheSize, long trimCacheSize){
TILE_MAX_CACHE_SIZE_BYTES = maxCacheSize * 1024 * 1024;
TILE_TRIM_CACHE_SIZE_BYTES = trimCacheSize * 1024 * 1024;
}
}