Skip to content

Instantly share code, notes, and snippets.

@sebastianknopf
Created October 29, 2018 19:05
Show Gist options
  • Save sebastianknopf/b9061c65f376d53da586bd126122699c to your computer and use it in GitHub Desktop.
Save sebastianknopf/b9061c65f376d53da586bd126122699c to your computer and use it in GitHub Desktop.
using osmdroid without external storage permission
// activity code goes here
// ...
/*
* To avoid the normally required permission ACCESS_EXTERNAL_STORAGE the osmdroid library
* offers a way to change the base path and the caching path to any other directory.
* We change these directories before initializing our MapView object, so osmdroid
* will NOT need the permission called above.
*
* Note that directories are also objects of type File in Java!
*/
Configuration.getInstance().setOsmdroidBasePath(new File(this.getFilesDir() + "/osmdroid/base"));
Configuration.getInstance().setOsmdroidTileCache(new File(this.getFilesDir() + "/osmdroid/cache"));
this.mapView = this.findViewById(R.id.map_view);
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment