Android Question Open any file located in StorageCard main directory

ashrafidkaidek

Member
Licensed User
Longtime User
I have a file “aaa.kml” located in my device storage card main directory, when I click on this files; Google map will open automatically and show the map based on kml file information.

Is there an easy way to call this “aaa.kml” file (located in device main storage card directory) from my app?

Thank you all
 

NJDude

Expert
Licensed User
Longtime User
Try this:
B4X:
Dim i As Intent
Dim mFile As String

mFile = File.Combine(File.DirDefaultExternal, "aaa.kml") 'or wherever you have saved the file

i.Initialize(i.ACTION_VIEW, "geo:0,0?q=file:///" & mFile)

StartActivity(i)
 
Last edited:
Upvote 0

ashrafidkaidek

Member
Licensed User
Longtime User
Thanks NJDude, the code you suggested will give the option to chose to open Google Earth, but once it opens it try to search for "file:///AssetsDir/aaa.kml" then fails to find that search string, it seems to me that above code lets Google Earth think that aaa.kml is just a location name or soothing of that sort ...
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Ok, this works:
B4X:
Dim i As Intent
Dim myKML As String

myKML = File.Combine(File.DirDefaultExternal, "aaa.kml")

i.Initialize(i.ACTION_VIEW, "file:///" & myKML)

i.SetComponent("com.google.earth/.EarthActivity")

StartActivity(i)
 
Upvote 0
Top