samedi 22 août 2015

Update/replace row if same ID already exists

I have the below method which inserts values in my sqlite db. I'm trying to update the code to handle situations where "carid" and "sellerno" already exist in the table and if they do to replace with the new values being inserted. Any help is appreciated.

public void addListItem(String carid,String sellerno,String condition,String dat) {

  SQLiteDatabase db = this.getWritableDatabase();

  ContentValues values = new ContentValues();
  values.put(carid, carid);
  values.put(sellerno, sellerno);
  values.put(cond, condition);
  values.put(updatetime, dat);
  db.insert(TABLE_CARS, null, values);
  db.close(); 
}

Aucun commentaire:

Enregistrer un commentaire