Android Question OSMDroid map not showing

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Using OSMDroid 4.1, for a few years with no problems. Data is in 2 SQLite files as I have 2 map types: Mapnik and OSMPublicTransport. File extensions are .mbtiles for both.
Recently there was an Android update, causing serious troubles, mainly with accessing the SD card but that has been solved by moving the main database (not the map files) to File.DirInternal.
As far as I know the OSMDroid databased need to be in File.DirRootExternal & "/osmdroid/" and I still have it there. I think it has to be there so the map data can be cached.
Now for some reason no map data is showing at all. No error message, just nil showing. When stepping through the code nil unusual is happening.
I tried moving the map databases to File.DirInternal & "/osmdroid", but no difference.
The tile source is set like this:

B4X:
Dim TileSourceFactory1 As OSMDroid_TileSourceFactory
MapView1.SetTileSource(TileSourceFactory1.GetTileSource("Mapnik"))

Any idea what the problem could be here?

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User

I think the problem is that now osmdroid can't read File.DirRootExternal & "/osmdroid/" as discussed in this thread:

No idea yet how to solve it.
Moving the osmdroid folder to File.DirInternal doesn't work.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I made progress with this, but just need to figure out how to rename a file in File.DirInternal & "/osmdroid/".
Actuallly I need to alter the file extension from .mbtiles to something like .txt or vice-versa.
Or somehow make a file temporary unavailable by other means. I don't want to copy and delete as that will
be too slow.

For a rename I have:

B4X:
Sub RenameFile(DirName As String, FileName As String, NewDirName As String, NewFileName As String) As Boolean
    
    Dim Source As JavaObject
    Dim Dest As JavaObject
    
    Source.InitializeNewInstance("java.io.File", Array(DirName,FileName))
    Dest.InitializeNewInstance("java.io.File", Array(NewDirName,NewFileName))
    Return Source.RunMethod("renameTo", Array As Object(Dest))
    
End Sub

But that doesn't work on files in File.DirInternal & "/osmdroid/"

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User

The function I posted (I think it came from Erel) works actually fine with File.DirRootExternal & "/osmdroid/"
I posted File.DirInternal, but that should have been File.DirRootExternal.
The problem was somewhere else, to do with renaming (to activate or deactivate) the mbtiles databases.
All sorted now and sorry to have caused any confusion, it was caused by the confusing situation regarding the different
folder types and the different permissions.

RBS
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…