Finding the distance between 2 points in Android using Cursor and the distanceTo() method

Posted by LordSnoutimus on Stack Overflow See other posts from Stack Overflow or by LordSnoutimus
Published on 2010-03-29T20:07:33Z Indexed on 2010/03/29 20:13 UTC
Read the original article Hit count: 629

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about android

Related posts about java