public int updateUser(User user) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_PASSWORD, user.getPassword()); values.put(KEY_TOKEN, user.getToken()); values.put(KEY_USER_ID, user.getUserId()); values.put(KEY_USERNAME, user.getUsername()); values.put(KEY_DATE_CREATED, user.getDateCreated()); values.put(KEY_FIRST_NAME, user.getFirstName()); values.put(KEY_LAST_NAME, user.getLastName()); values.put(KEY_GENDER, user.getGender()); values.put(KEY_USER_STATUS, user.getStatus()); // updating row return db.update( TABLE_USER, values, KEY_USER_ID + " = ?", new String[] {String.valueOf(user.getUserId())}); }
void addUser(User user) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put(KEY_PASSWORD, user.getPassword()); values.put(KEY_TOKEN, user.getToken()); values.put(KEY_USERNAME, user.getUsername()); values.put(KEY_DATE_CREATED, user.getDateCreated()); values.put(KEY_FIRST_NAME, user.getFirstName()); values.put(KEY_LAST_NAME, user.getLastName()); values.put(KEY_GENDER, user.getGender()); values.put(KEY_USER_STATUS, user.getStatus()); // Insert Row db.insert(TABLE_USER, null, values); db.close(); }