コード例 #1
0
 @Override
 protected void reloadBook(Book book) {
   final Cursor cursor =
       myDatabase.rawQuery(
           "SELECT title,encoding,language FROM Books WHERE book_id = " + book.getId(), null);
   if (cursor.moveToNext()) {
     book.setTitle(cursor.getString(0));
     book.setEncoding(cursor.getString(1));
     book.setLanguage(cursor.getString(2));
   }
   cursor.close();
 }
コード例 #2
0
 @Override
 protected void setExistingFlag(Collection<Book> books, boolean flag) {
   if (books.isEmpty()) {
     return;
   }
   final StringBuilder bookSet = new StringBuilder("(");
   boolean first = true;
   for (Book b : books) {
     if (first) {
       first = false;
     } else {
       bookSet.append(",");
     }
     bookSet.append(b.getId());
   }
   bookSet.append(")");
   myDatabase.execSQL(
       "UPDATE Books SET `exists` = " + (flag ? 1 : 0) + " WHERE book_id IN " + bookSet);
 }