// addContacts public void addContact(Contact contact) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_NAME, contact.getName()); values.put(KEY_PH_NO, contact.getPhoneNumber()); db.insert(TABLE_CONTACTS, null, values); db.close(); }
// updateContact public int updateContact(Contact contact) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_ID, contact.getID()); values.put(KEY_NAME, contact.getName()); values.put(KEY_PH_NO, contact.getPhoneNumber()); return db.update( TABLE_CONTACTS, values, KEY_ID + "=?", new String[] {String.valueOf(contact.getID())}); }