public void writeTrackPoints(String trackName,FileWriter fw,DBtrackingPoints db) throws IOException {
  db.open();
  Cursor c=db.getCursor();
  DBhelper dBhelper=db.getDbHelper();
  fw.write("\t" + "<trk>" + "\n");
  fw.write("\t\t" + "<name>" + "PocketMaps GPS track log"+ "</name>"+ "\n");
  fw.write("\t\t" + "<trkseg>" + "\n");
  while (!c.isAfterLast()) {
    StringBuffer out=new StringBuffer();
    out.append("\t\t\t" + "<trkpt lat=\"" + c.getDouble(c.getColumnIndex(dBhelper.COLUMN_LATITUDE)) + "\" "+ "lon=\""+ c.getDouble(c.getColumnIndex(dBhelper.COLUMN_LONGITUDE))+ "\">");
    out.append("<ele>" + c.getDouble(c.getColumnIndex(dBhelper.COLUMN_ALTITUDE)) + "</ele>");
    out.append("<time>" + DF.format(new Date(c.getLong(c.getColumnIndex(dBhelper.COLUMN_DATETIME)))) + "</time>");
    out.append("</trkpt>" + "\n");
    fw.write(out.toString());
    c.moveToNext();
  }
  db.close();
  fw.write("\t\t" + "</trkseg>" + "\n");
  fw.write("\t" + "</trk>" + "\n");
}

public void writeTrackPoints ( String trackName , FileWriter fw , DBtrackingPoints db ) throws IOException { db . open ( ) ; Cursor c = db . getCursor ( ) ; DBhelper dBhelper = db . getDbHelper ( ) ; fw . write ( "\t" + "<trk>" + "\n" ) ; fw . write ( "\t\t" + "<name>" + "PocketMaps GPS track log" + "</name>" + "\n" ) ; fw . write ( "\t\t" + "<trkseg>" + "\n" ) ; while ( ! c . isAfterLast ( ) ) { StringBuffer out = new StringBuffer ( ) ; out . append ( "\t\t\t" + "<trkpt lat=\"" + c . getDouble ( c . getColumnIndex ( dBhelper . COLUMN_LATITUDE ) ) + "\" " + "lon=\"" + c . getDouble ( c . getColumnIndex ( dBhelper . COLUMN_LONGITUDE ) ) + "\">" ) ; out . append ( "<ele>" + c . getDouble ( c . getColumnIndex ( dBhelper . COLUMN_ALTITUDE ) ) + "</ele>" ) ; out . append ( "<time>" + DF . format ( new Date ( c . getLong ( c . getColumnIndex ( dBhelper . COLUMN_DATETIME ) ) ) ) + "</time>" ) ; out . append ( "</trkpt>" + "\n" ) ; fw . write ( out . toString ( ) ) ; c . moveToNext ( ) ; } db . close ( ) ; fw . write ( "\t\t" + "</trkseg>" + "\n" ) ; fw . write ( "\t" + "</trk>" + "\n" ) ; }
iterates on track points and write them .
