Sqlite update query operation in Android Part – 6

 

This Video shows What is Basic update operation in Android? The Update Operation performs an UPDATE statement on the table based on the primary key for a record specified in the ‘WHERE’ clause of the statement. Same as the Create procedure it has one parameter for every column in the table.
The Update() method is used for modifying a subset of database values.
Example:
public int updateContact(Contact contact) {
SQLiteDatabase db = this.getWritableDatabase();

ContentValues values = new ContentValues();
values.put(KEY_NAME, contact.getName());
values.put(KEY_PH_NO, contact.getPhoneNumber());

// updating row
return db.update(TABLE_CONTACTS, values, KEY_ID + ” = ?”,
new String[] { String.valueOf(contact.getID()) });
}


Leave a Reply

Your email address will not be published. Required fields are marked *