我正在使用 while 循环遍历游标,然后输出数据库中每个点的经度和纬度值。
由于某种原因,它没有返回游标中的最后一个(或第一个取决于我是否使用 Cursor.MoveToLast)经度和纬度值集。
这是我的代码:
public void loadTrack() {
SQLiteDatabase db1 = waypoints.getWritableDatabase();
Cursor trackCursor = db1.query(TABLE_NAME, FROM, "trackidfk=1", null, null, null,ORDER_BY);
trackCursor.moveToFirst();
while (trackCursor.moveToNext()) {
Double lat = trackCursor.getDouble(2);
Double lon = trackCursor.getDouble(1);
//overlay.addGeoPoint( new GeoPoint( (int)(lat*1E6), (int)(lon*1E6)));
System.out.println(lon);
System.out.println(lat);
}
}
从这里我得到:
*******************************************
04-02 15:39:07.416: INFO/System.out(10551): 3.0
04-02 15:39:07.416: INFO/System.out(10551): 5.0
04-02 15:39:07.416: INFO/System.out(10551): 4.0
04-02 15:39:07.416: INFO/System.out(10551): 5.0
04-02 15:39:07.416: INFO/System.out(10551): 5.0
04-02 15:39:07.416: INFO/System.out(10551): 5.0
04-02 15:39:07.416: INFO/System.out(10551): 4.0
04-02 15:39:07.416: INFO/System.out(10551): 4.0
04-02 15:39:07.416: INFO/System.out(10551): 3.0
04-02 15:39:07.416: INFO/System.out(10551): 3.0
04-02 15:39:07.416: INFO/System.out(10551): 2.0
04-02 15:39:07.416: INFO/System.out(10551): 2.0
04-02 15:39:07.493: INFO/System.out(10551): 1.0
04-02 15:39:07.493: INFO/System.out(10551): 1.0
***************************************************************
7 Sets of values, where I should be getting 8 sets.
谢谢。