I use a while loop to iterate over the cursor and then output the longitude and latitude values โโof each point in the database.
For some reason, it does not return the last (or the first, depending on whether I use Cursor.MoveToLast) a set of longitude and latitude values โโin the cursor.
Here is my code:
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);
From this I get:
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 the values โโwhere I should receive 8 sets.
Thanks.
java android sql sqlite cursor
jcrowson
source share