Search code examples
javaandroidxamarinkml

How to load KML File in folder Assets with Xamarin Android


I put my file into the Assets directory and set the build action to "AndroidAsset"

Nevertheless, I can't access my KML file using the parseKmlFile method

I need to affect my Kml file to a Java.IO.File but the file I placed doesn't exist.

        Java.IO.File file = new Java.IO.File ("file:///android_asset/Content/maplayer.kml");
        Java.IO.File file2 = new Java.IO.File ("Content/maplayer.kml");
        Java.IO.File file3 = new Java.IO.File ("/Content/maplayer.kml");
        Java.IO.File file4 = new Java.IO.File ("maplayer.kml");

        if (file.Exists ())             
        Log.Debug ("File IO", file.ToString ());
        if (file2.Exists ())        
        Log.Debug ("File IO", file2.ToString ());
        if (file3.Exists ())        
        Log.Debug ("File IO", file3.ToString ());
        if (file4.Exists ())        
        Log.Debug ("File IO", file4.ToString ());

My file is located to : Assets/Content/maplayer.kml

I verified that asset is without S and that I have 3 "/" So where is my Kml file located ?


Solution

  • I think that you can do it like it was a Xml file, but see if this or this helps you.