Reputation: 121
I'm trying to create a KML file using XmlSerializer, but when I open the file this is truncated to 500 bytes only.
I don't understand why?
my code:
public void onCreatXML() {
KML kml = new KML();
try {
XmlSerializer xmlSerializer = Xml.newSerializer();
writer = new StringWriter();
xmlSerializer.setOutput(writer);
//Start document
xmlSerializer.startDocument("UTF-8", true);
//Open tag
xmlSerializer.startTag("", KML.KML);
xmlSerializer.startTag("", KML.DOCUMENT);
----
onWrite(writer.toString());
} catch (Exception e){
e.printStackTrace();
}
}
public void onWrite (String writer) {
FileOutputStream fic;
String loc;
String zaza = "ROCKWELL COLLINS";
try{
context.deleteFile("Test.kml");
fic = context.openFileOutput("Test.kml", Context.MODE_PRIVATE);
OutputStreamWriter wfic = new OutputStreamWriter(fic);
wfic.write(writer);
wfic.close();
}catch (Exception e){
e.printStackTrace();
}
}
Thanks for you help.
Upvotes: 0
Views: 91
Reputation: 121
I found the solution, i forget to close the doc before write it. I just add a xmlSerializer.endDocument after closing tags, and it works
Thanks to all
Upvotes: 1