Android SQLite: Update Statement

vivek_Android picture vivek_Android · May 13, 2011 · Viewed 176.3k times · Source

I need to implement SQLite in my application. I followed this tutorial.. Creating and using databases in Android one

Everything is working fine. I inserted 1 row with 5 columns. Now I want to update value of 1 column only and others will be remain same.

There is one update method in tutorial but it needs all the parameters, however I want to update only one column.

Answer

Nikhil picture Nikhil · May 13, 2011

You can use the code below.

String strFilter = "_id=" + Id;
ContentValues args = new ContentValues();
args.put(KEY_TITLE, title);
myDB.update("titles", args, strFilter, null);