private TrackDob cursorToLocation(Cursor cursor) { TrackDob trackDob = new TrackDob(); trackDob.setId(cursor.getLong(0)); trackDob.setTag(cursor.getString(1)); trackDob.setStartTime(cursor.getLong(2)); trackDob.setFirstLat(cursor.getDouble(3)); trackDob.setFirstLon(cursor.getDouble(4)); trackDob.setFirstAddress(cursor.getString(5)); trackDob.setFinishTime(cursor.getLong(6)); trackDob.setLastLat(cursor.getDouble(7)); trackDob.setLastLon(cursor.getDouble(8)); trackDob.setLastAddress(cursor.getString(9)); trackDob.setDistance(cursor.getFloat(10)); trackDob.setMaxSpeed(cursor.getFloat(11)); trackDob.setAveSpeed(cursor.getFloat(12)); trackDob.setMinAlt(cursor.getDouble(13)); trackDob.setMaxAlt(cursor.getDouble(14)); trackDob.setElevDiffUp(cursor.getDouble(15)); trackDob.setElevDiffDown(cursor.getDouble(16)); trackDob.setNote(cursor.getString(17)); trackDob.setUpdateTime(cursor.getLong(18)); return trackDob; }
public Long saveTrack(TrackDob trackDob) { long insertId = -1; try { ContentValues values = new ContentValues(); values.put(COL_TAG, trackDob.getTag()); values.put(COL_START_TIME, trackDob.getStartTime()); values.put(COL_FIRST_LAT, trackDob.getFirstLat()); values.put(COL_FIRST_LON, trackDob.getFirstLon()); values.put(COL_FIRST_ADDRESS, trackDob.getFirstAddress()); values.put(COL_FINISH_TIME, trackDob.getFinishTime()); values.put(COL_LAST_LAT, trackDob.getLastLat()); values.put(COL_LAST_LON, trackDob.getLastLon()); values.put(COL_LAST_ADDRESS, trackDob.getLastAddress()); values.put(COL_DISTANCE, trackDob.getDistance()); values.put(COL_MAX_SPEED, trackDob.getMaxSpeed()); values.put(COL_AVE_SPEED, trackDob.getAveSpeed()); values.put(COL_MAX_ALT, trackDob.getMaxAlt()); values.put(COL_MIN_ALT, trackDob.getMinAlt()); values.put(COL_ELEV_DIFF_UP, trackDob.getElevDiffUp()); values.put(COL_ELEV_DIFF_DOWN, trackDob.getElevDiffDown()); values.put(COL_NOTE, trackDob.getNote()); insertId = DatabaseManager.getDb().insert(TABLE_NAME, null, values); if (Const.LOG_ENHANCED) Log.i(TAG, "Track successfully saved with id = " + insertId); } catch (Exception e) { Log.e(TAG, "Cannot save track", e); } return insertId; }