Finding the distance between 2 points in Android using Cursor and the distanceTo() method
- by LordSnoutimus
Hello,
I am trying to calculate the distance between the first GPS point stored in a SQLite database and the last GPs point stored.
My code so far is this:
private double Distance()
{
SQLiteDatabase db1 = waypoints.getWritableDatabase();
Cursor cursor = db1.query(TABLE_NAME, FROM, null, null, null, null,ORDER_BY);
Cursor cursor1 = db1.query(TABLE_NAME, FROM, null, null, null, null,ORDER_BY);
Double lat = cursor.getDouble(2);
Double lon = cursor.getDouble(1);
cursor.moveToFirst();
cursor.moveToLast();
cursor.close();
distance = cursor.distanceTo(cursor1);
}
I realise I need to return a value but the error I am receiving is for the distanceTo method
"The method distanceTo(Cursor) is undefined for the type Cursor"
Thanks.