public long insertSetting(SettingsWeather settingsW) { ContentValues values = new ContentValues(); values.put(UserSettingsDbHelper.COLUMN_BACKGROUND_COLOR, settingsW.getBackgroundColor()); values.put(UserSettingsDbHelper.COLUMN_CITY_LIST_SORT, settingsW.getCityStateListSort()); values.put(UserSettingsDbHelper.COLUMN_DISPLAY_TYPE, settingsW.getPanelSelectInt()); long insertId = database.insert(UserSettingsDbHelper.TABLE, null, values); // if(insertId != -1) { // Cursor cursor = database.query(CityListDbHelper.TABLE, // allColumns, CityListDbHelper.COLUMN_ID + " = " + insertId, null, // null, null, null); // cursor.moveToFirst(); // newBuilding = cursorToBuilding(cursor); // cursor.close(); // } if (GlobalSettings.city_list_db_data) Log.d(UserSettingsDbData.class.getName() + "insertSetting()", "insertId: " + insertId); return insertId; }
public long updateSetting(SettingsWeather settingsW) { ContentValues values = new ContentValues(); SettingsWeather swFirst = getSavedSettings(); // gets first record. Update this using the ID values.put(UserSettingsDbHelper.COLUMN_BACKGROUND_COLOR, settingsW.getBackgroundColor()); values.put(UserSettingsDbHelper.COLUMN_CITY_LIST_SORT, settingsW.getCityStateListSort()); values.put(UserSettingsDbHelper.COLUMN_DISPLAY_TYPE, settingsW.getPanelSelectInt()); long insertId = database.update( UserSettingsDbHelper.TABLE, values, UserSettingsDbHelper.COLUMN_ID + " = " + swFirst.getID(), null); if (GlobalSettings.city_list_db_data) Log.d(UserSettingsDbData.class.getName() + "updateSetting()", "insertId: " + insertId); return insertId; }