0

I want to read a KML file that exists on the android mobile directory(sd card ) and I want to get the information from this file and display it on the screen.

this is the KML file that I have :

<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"          xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
    <Placemark>
        <name>Simple placemark</name>
        <description>Attached to the ground. Intelligently places itself at the
              height of the underlying terrain.</description>    
        <Point>
            <coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
        </Point>
    </Placemark>
  </kml>

1 Answer 1

2

Just parse it as you parse XML. Here's my take on it. Hope this help: https://gist.github.com/3163006

Sign up to request clarification or add additional context in comments.

5 Comments

I dont have a URL I have a file in the mobile directory
Well, you can read and scan external memory for all file with .kml at the end but that's gonna be slow tho. Unless you can fix directory in which your KML files to be stored then just read that directory and you are done. Like this: File dir =new File(android.os.Environment.getExternalStorageDirectory(),"myKmlDirectory"); Just dont forget to add permission to manifest file.
Read External storage permission is added in JellyBean(Android 4.1)
the code in the link that u provided for me >> there is no On create method >> where should I start ?/
GetNavigationDataSet(String url) method. Mine was set up to parse from URL but I guess you could take xr.parse(new InputSource(aUrl.openStream())); line and change aUrl.openStream() to the InputStream of the File you want to open.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.