public boolean update(Book book) { boolean updated = false; try { open(); ContentValues cv = new ContentValues(); cv.put(DBHelper.KEY_TITLE, book.getTitle()); cv.put(DBHelper.KEY_AUTHOR, book.getAuthor()); updated = getDB() .update( DBHelper.TABLE_BOOKS, cv, DBHelper.KEY_ID + " = ?", new String[] {String.valueOf(book.getId())}) > 0; close(); } catch (SQLException e) { e.printStackTrace(); } finally { close(); } return updated; }
public boolean delete(Book book) { boolean deleted = false; try { open(); String whereClause = DBHelper.KEY_ID + " = " + book.getId(); deleted = getDB().delete(DBHelper.TABLE_BOOKS, whereClause, null) > 0; close(); } catch (SQLException e) { e.printStackTrace(); } finally { close(); } return deleted; }