I am trying to create a score database that increases the score of players by one when they win by calling updateScore (). The primary key and the player number are identical (I may need to restructure the database at some point), and the last column is βscoreβ.
Below is the code that initially sets the score (this works), the method that gets the score (also works great), and the method that updates the score, increasing the number of relevant players by 1. This is the part that I'm working on, is there anything what should i do differently here? Thank you
public void addScore (int playerId, int playerScore) { SQLiteDatabase database = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(ID, playerId); values.put(PLAYERNUM, playerId); values.put(SCORE, playerScore); database.insert(TABLE_2PSCORES, null, values); database.close(); }
android sqlite
davidbain
source share