// Adding value to points category of a player public int addStats(long g_id, long p_id, String stat, int value) { SQLiteDatabase db = this.getWritableDatabase(); HockeyGameStats stats = getPlayerGameStats(g_id, p_id); int old_value = getPlayerGameStat(g_id, p_id, stat); int new_value = old_value + value; ContentValues values = new ContentValues(); values.put(KEY_P_ID, p_id); values.put(KEY_G_ID, g_id); if (stat == KEY_SHOTS) values.put(KEY_SHOTS, new_value); else values.put(KEY_SHOTS, stats.getshots()); if (stat == KEY_SOG) values.put(KEY_SOG, new_value); else values.put(KEY_SOG, stats.getsog()); if (stat == KEY_GOALS) values.put(KEY_GOALS, new_value); else values.put(KEY_GOALS, stats.getgoals()); if (stat == KEY_AST) values.put(KEY_AST, new_value); else values.put(KEY_AST, stats.getast()); if (stat == KEY_PEN_MINOR) values.put(KEY_PEN_MINOR, new_value); else values.put(KEY_PEN_MINOR, stats.getpenminor()); if (stat == KEY_PEN_MAJOR) values.put(KEY_PEN_MAJOR, new_value); else values.put(KEY_PEN_MAJOR, stats.getpenminor()); if (stat == KEY_PEN_MISCONDUCT) values.put(KEY_PEN_MISCONDUCT, new_value); else values.put(KEY_PEN_MISCONDUCT, stats.getpenmisconduct()); if (stat == KEY_SAVES) values.put(KEY_SAVES, new_value); else values.put(KEY_SAVES, stats.getsaves()); if (stat == KEY_GOALS_ALLOWED) values.put(KEY_GOALS_ALLOWED, new_value); else values.put(KEY_GOALS_ALLOWED, stats.getgoalsallowed()); // insert more stats here return db.update( TABLE_HOCKEY_GAME_STATS, values, KEY_P_ID + " = " + p_id + " AND " + KEY_G_ID + " = " + g_id, null); }