public void delete(TTSQLiteOpenHelper openHelper) { SQLiteDatabase db = openHelper.getWritableDatabase(); db.delete(TABLE_STOPS, COLUMN_MAP_ID + " = " + id, null); db.delete(TABLE_WAYPOINTS, COLUMN_MAP_ID + " = " + id, null); db.delete(TABLE_LOCATIONS, COLUMN_MAP_ID + " = " + id, null); db.delete(TABLE_MAPS, COLUMN_ID + " = " + id, null); }
public static final Map instanceOf(TTSQLiteOpenHelper sqLiteOpenHelper, int mapId) { Map map = new Map(); SQLiteDatabase database = sqLiteOpenHelper.getReadableDatabase(); Cursor cursor = database.query( TABLE_MAPS, ALL_MAP_COLUMNS, COLUMN_ID + " = " + mapId, null, null, null, null); cursor.moveToFirst(); map.id = mapId; map.name = cursor.getString(cursor.getColumnIndex(COLUMN_NAME)); map.startTime = cursor.getInt(cursor.getColumnIndex(COLUMN_START_TIME)); map.endTime = cursor.getInt(cursor.getColumnIndex(COLUMN_END_TIME)); map.averageSpeed = cursor.getFloat(cursor.getColumnIndex(COLUMN_AVERAGE_SPEED)); map.totalDistance = cursor.getFloat(cursor.getColumnIndex(COLUMN_TOTAL_DISTANCE)); map.linearDistance = cursor.getFloat(cursor.getColumnIndex(COLUMN_LINEAR_DISTANCE)); map.maximumSpeed = cursor.getFloat(cursor.getColumnIndex(COLUMN_MAXIMUM_SPEED)); map.maximumAltitude = cursor.getFloat(cursor.getColumnIndex(COLUMN_MAX_ALTITUDE)); map.minimumAltitude = cursor.getFloat(cursor.getColumnIndex(COLUMN_MIN_ALTITUDE)); map.startAltitude = cursor.getFloat(cursor.getColumnIndex(COLUMN_START_ALTITUDE)); map.endAltitude = cursor.getFloat(cursor.getColumnIndex(COLUMN_END_ALTITUDE)); map.notes = cursor.getString(cursor.getColumnIndex(COLUMN_NOTES)); cursor.close(); map.locations = TTLocation.getAll(sqLiteOpenHelper, mapId); map.waypoints = Waypoint.getAll(sqLiteOpenHelper, mapId); map.stops = Stop.getAll(sqLiteOpenHelper, mapId); return map; }