public boolean saveAsKML(Writer writer){
  try {
    writer.write("<?xml version='1.0' encoding='UTF-8'?>\n");
    writer.write("<kml xmlns='http://www.opengis.net/kml/2.2'>\n");
    boolean result=true;
    if (mKmlRoot != null)     result=mKmlRoot.writeAsKML(writer,true,this);
    writer.write("</kml>\n");
    return result;
  }
 catch (  IOException e) {
    e.printStackTrace();
    return false;
  }
}

public boolean saveAsKML ( Writer writer ) { try { writer . write ( "<?xml version='1.0' encoding='UTF-8'?>\n" ) ; writer . write ( "<kml xmlns='http://www.opengis.net/kml/2.2'>\n" ) ; boolean result = true ; if ( mKmlRoot != null ) result = mKmlRoot . writeAsKML ( writer , true , this ) ; writer . write ( "</kml>\n" ) ; return result ; } catch ( IOException e ) { e . printStackTrace ( ) ; return false ; } }
save the document as a kml file on writer
