3

I am trying to increment the value in a row by 5. I have searched here and Google but so far have not found and answer that works. Below is what seems to have the least amount of errors from Eclipse.

private static String[] table_scores = {DHObject.TABLE_SCORES,};
private static String[] column_tokens = {DHObject.COLUMN_TOKENS,};
private static String[] column_points = {DHObject.COLUMN_POINTS,};
private static String[] column_num = {DHObject.COLUMN_NUM,};

public Cursor onCorrectAnswer() {
    rawQuery(table_scores, [column_tokens = column_tokens + 5], column_num 0);
    rawQuery(table_scores, [column_points = column_points + 5], column_num 0);
}
2
  • You should post some more code. What does your rawQuery method do? What you have written isn't even proper java syntax... Commented May 31, 2014 at 7:20
  • Thank You for responding. I am very new to this and have been putting myself through as much training as I can find, which is still quite lacking. Basically all I am trying to do here to increment or add 5 points and 5 tokens to the tokens tally. The tallies are in a SQLite table called TABLE_SCORES with _num being the key and a column for tokens and another for points. I have only one row which is row 0. I got the structure for this rawQuery from here but it had red lines under everything. I went to the SQLite sect on the android dev site and tried to structure the query from there. Commented May 31, 2014 at 7:51

1 Answer 1

4

To increment a column's values, you have to execute an SQL statement like this:

UPDATE Scores
SET Tokens = Tokens + 5,
    Points = Points + 5
WHERE Num = 0;
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you again. I'm a newbie, I have been using Lynda.com and The Busy Coder for Training resources. Apart from just getting on with it are there any other training resources you would suggest?. Kind Regards, Derek

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.