I understand the title may sound confusing, but the goal is very clear:
I am building an application that requires two tables: tracks and waypoints.
A user enters the track name via a textfield and the table generates an ID under track_id.
in the waypoints table there is a column called track_id_fk. When the OnLocationChanged() method is called, the longitude and latitude is entered into the table, along with the time.
I want to add the track_id of the newest track entry in the track table to the track_id_fk column in the waypoints table.
I am using the following code:
SQLiteDatabase db = waypoints.getWritableDatabase();
ContentValues waypointvalues = new ContentValues();
waypointvalues.put(LONGITUDE, loc.getLongitude());
waypointvalues.put(LATITUDE, loc.getLatitude());
waypointvalues.put(TIME, System.currentTimeMillis());
waypointvalues.put(TRACK_ID_FK, "last inserted trackid");
db.insertOrThrow(TABLE_NAME, null, waypointvalues);
I am unsure as to what the value should be where "last inserted trackid" is.
Thanks