Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android sqlite increment a column value

Tags:

android

sqlite

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);
}
like image 752
nybler42 Avatar asked Aug 03 '26 03:08

nybler42


1 Answers

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;
like image 188
CL. Avatar answered Aug 04 '26 19:08

CL.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!