Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increment field in sqlite android database

I want to increment a column in a sqlite android database. Im doing like this:

public void atualiza(String word){
   this.db.rawQuery("UPDATE words SET count = count + 1 WHERE word= ? ", new String[] {word});     
}

And I call this method on another class like this:

this.dh.atualiza(word); 

But when i pull the database from the emulator and check with the SQLite Database Browser, the field is not incremented. Why?

like image 465
rogcg Avatar asked Oct 14 '22 01:10

rogcg


1 Answers

You should really use execSQL for a query that does not return a table: Increase the value of a record in android/sqlite database

like image 147
MPelletier Avatar answered Oct 20 '22 01:10

MPelletier