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}); 开发者_JAVA百科
}
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?
You should really use execSQL
for a query that does not return a table: Increase the value of a record in android/sqlite database
You need to start a transaction on the database Data not inserting in Sqlite database in android
精彩评论