/** * Add a record to RecentBooks table * * @param recentBooks */ public void addRecentBook(DaisyBookInfo recentBooks) { ContentValues mValue = new ContentValues(); mValue.put(NAME_KEY_RECENT_BOOKS, recentBooks.getTitle()); mValue.put(PATH_KEY_RECENT_BOOKS, recentBooks.getPath()); mValue.put(SORT_KEY_RECENT_BOOKS, recentBooks.getSort()); try { SQLiteDatabase mdb = getWritableDatabase(); mdb.insert(TABLE_NAME_RECENT_BOOKS, null, mValue); mdb.close(); } catch (Exception e) { PrivateException ex = new PrivateException(e, mContext); ex.writeLogException(); } }
/** * Update a record of RecentBooks table * * @param recentBooks */ public void updateRecentBook(DaisyBookInfo recentBooks) { ContentValues mValue = new ContentValues(); mValue.put(SORT_KEY_RECENT_BOOKS, recentBooks.getSort()); try { SQLiteDatabase mdb = getWritableDatabase(); mdb.update( TABLE_NAME_RECENT_BOOKS, mValue, NAME_KEY_RECENT_BOOKS + "=?", new String[] {recentBooks.getTitle()}); mdb.close(); } catch (Exception e) { PrivateException ex = new PrivateException(e, mContext); ex.writeLogException(); } }