コード例 #1
0
 public static void insertToBookFav(ContentResolver resolver, Book bookinfo) {
   ContentValues values = new ContentValues();
   values.put(DbTags.FIELD_BOOK_NAME, bookinfo.getBookName());
   values.put(DbTags.FIELD_BOOK_PATH, bookinfo.getBookPath());
   values.put(DbTags.FIELD_BOOK_ADD_TIME, bookinfo.getBookAddTime());
   values.put(DbTags.FIELD_BOOK_SIZE, bookinfo.getBookSize());
   resolver.insert(Uri.parse(DbTags.URI_TABLE_BOOK_FAV), values);
 }
コード例 #2
0
  public static Book queryBookFav(ContentResolver resolver, String tag, String key) {
    Book book = null;
    Cursor cursor =
        resolver.query(
            Uri.parse(DbTags.URI_TABLE_BOOK_FAV), null, tag + "=?", new String[] {key + ""}, null);
    if (cursor.moveToNext()) {
      book = new Book();

      book.setBookName(getFieldContent(cursor, DbTags.FIELD_BOOK_NAME));
      book.setBookPath(getFieldContent(cursor, DbTags.FIELD_BOOK_PATH));
      book.setBookAddTime(getFieldContent(cursor, DbTags.FIELD_BOOK_ADD_TIME));
      book.setBookSize(getFieldContent(cursor, DbTags.FIELD_BOOK_SIZE));
    }
    cursor.close();
    return book;
  }
コード例 #3
0
 public static void insertToBookInfo(ContentResolver resolver, Book bookinfo) {
   ContentValues values = new ContentValues();
   values.put(DbTags.FIELD_BOOK_NAME, bookinfo.getBookName());
   values.put(DbTags.FIELD_BOOK_AUTHOR, bookinfo.getBookAuthor());
   values.put(DbTags.FIELD_BOOK_PATH, bookinfo.getBookPath());
   values.put(DbTags.FIELD_BOOK_ADD_TIME, bookinfo.getBookAddTime());
   values.put(DbTags.FIELD_BOOK_OPEN_TIME, bookinfo.getBookOpenTime());
   values.put(DbTags.FIELD_BOOK_CATEGORY_ID, bookinfo.getBookCategoryId());
   values.put(DbTags.FIELD_BOOK_CATEGORY_NAME, bookinfo.getBookCategroyName());
   values.put(DbTags.FIELD_BOOK_SIZE, bookinfo.getBookSize());
   values.put(DbTags.FIELD_BOOK_PROGRESS, bookinfo.getBookProgress());
   resolver.insert(Uri.parse(DbTags.URI_TABLE_BOOK_INFO), values);
 }
コード例 #4
0
  public static ArrayList<Book> queryBooksFav(ContentResolver resolver) {
    ArrayList<Book> bookList = new ArrayList<Book>();
    Book book;

    Cursor cursor = resolver.query(Uri.parse(DbTags.URI_TABLE_BOOK_FAV), null, null, null, null);
    while (cursor.moveToNext()) {
      book = new Book();

      book.setBookName(getFieldContent(cursor, DbTags.FIELD_BOOK_NAME));
      book.setBookPath(getFieldContent(cursor, DbTags.FIELD_BOOK_PATH));
      book.setBookAddTime(getFieldContent(cursor, DbTags.FIELD_BOOK_ADD_TIME));
      book.setBookSize(getFieldContent(cursor, DbTags.FIELD_BOOK_SIZE));
      bookList.add(book);
    }
    cursor.close();

    return bookList;
  }
コード例 #5
0
  public static ArrayList<Book> queryFilterBooks(ContentResolver resolver, String tag, String key) {
    ArrayList<Book> bookList = new ArrayList<Book>();
    Book book;

    Cursor cursor =
        resolver.query(
            Uri.parse(DbTags.URI_TABLE_BOOK_INFO), null, tag + "=?", new String[] {key + ""}, null);
    while (cursor.moveToNext()) {
      book = new Book();
      book.setBookId(Integer.parseInt(getFieldContent(cursor, DbTags.FIELD_BOOK_ID)));
      book.setBookName(getFieldContent(cursor, DbTags.FIELD_BOOK_NAME));
      book.setBookAuthor(getFieldContent(cursor, DbTags.FIELD_BOOK_AUTHOR));
      book.setBookPath(getFieldContent(cursor, DbTags.FIELD_BOOK_PATH));
      book.setBookAddTime(getFieldContent(cursor, DbTags.FIELD_BOOK_ADD_TIME));
      book.setBookOpenTime(getFieldContent(cursor, DbTags.FIELD_BOOK_OPEN_TIME));
      book.setBookCategoryId(
          Integer.parseInt(getFieldContent(cursor, DbTags.FIELD_BOOK_CATEGORY_ID)));
      book.setBookCategroyName(getFieldContent(cursor, DbTags.FIELD_BOOK_CATEGORY_NAME));
      book.setBookSize(getFieldContent(cursor, DbTags.FIELD_BOOK_SIZE));
      book.setBookProgress(getFieldContent(cursor, DbTags.FIELD_BOOK_PROGRESS));

      bookList.add(book);
    }
    cursor.close();

    return bookList;
  }