1

I'd like to update one of my table's column with the following query:

update TABLE set COLUMN_NAME= COLUMN_NAME+1;

using if posible the

update(String table, ContentValues values, String whereClause, String[] whereArgs)

method in SQLiteDatabase class in android Is that posible?

Thanks in advance

Starterrr
  • 13
  • 3

2 Answers2

0

though this is a bit overdue, i'm just adding an example that works...

SQLite version 3.7.9 2011-11-01 00:52:41
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table test1(a int primary key, b int);
sqlite> begin transaction;
sqlite> insert into test1(a,b) values (1,4);
sqlite> insert into test1(a,b) values (2,5);
sqlite> insert into test1(a,b) values (3,4);
sqlite> commit;
sqlite> select * from test1;
1|4
2|5
3|4
sqlite> update test1 set b=b+1;
sqlite> select * from test1;
1|5
2|6
3|5
sqlite> update test1 set b=b+10;
sqlite> select * from test1;
1|15
2|16
3|15
sqlite> 
root-11
  • 1,727
  • 1
  • 19
  • 33
0

You may have some luck with execSQL. Here's what I did to solve a similar problem:

db.beginTransaction();
try {
    //do update stuff, including execSQL()
    db.setTransactionSuccessful();
} finally {
    db.endTransaction();
}

See also https://stackoverflow.com/a/5575277/6027

Community
  • 1
  • 1
parkerfath
  • 1,648
  • 1
  • 12
  • 18