예제 #1
0
  public List<ViewItem> getPageInChapter(String chapterUrl) {
    List<ViewItem> list = new ArrayList<ViewItem>();
    try {
      String selectQuery =
          "SELECT  * FROM " + TABLE_PAGE + " r  " + "WHERE r.chapterUrl = '" + chapterUrl + "'";

      SQLiteDatabase db = this.getReadableDatabase();
      Cursor c = db.rawQuery(selectQuery, null);

      if (c.moveToFirst()) {
        do {
          ViewItem item = new ViewItem(c.getString(c.getColumnIndex("imageUrl")));
          item.setChapterUrl(c.getString(c.getColumnIndex("chapterUrl")));
          item.setFileUrl(c.getString(c.getColumnIndex("fileUrl")));
          item.setOrder(c.getInt(c.getColumnIndex("stt")));

          list.add(item);
        } while (c.moveToNext());
      }
      c.close();
    } catch (Exception e) {

    }
    return list;
  }
예제 #2
0
  public int updatePage(ViewItem item) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put("chapterUrl", item.getChapterUrl());
    values.put("imageUrl", item.getImageUrl());
    values.put("fileUrl", item.getFileUrl());
    values.put("stt", item.getOrder());

    // updating row
    return db.update(TABLE_PAGE, values, "chapterUrl = ?", new String[] {item.getChapterUrl()});
  }
예제 #3
0
  public long createPage(ViewItem item) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put("chapterUrl", item.getChapterUrl());
    values.put("imageUrl", item.getImageUrl());
    values.put("fileUrl", item.getFileUrl());
    values.put("stt", item.getOrder());

    // insert row
    long inserted_id = db.insert(TABLE_PAGE, null, values);

    return inserted_id;
  }
예제 #4
0
  public ViewItem getPage(String imageUrl) {
    try {
      String selectQuery =
          "SELECT  * FROM " + TABLE_PAGE + " r  " + "WHERE r.imageUrl = '" + imageUrl + "'";

      SQLiteDatabase db = this.getReadableDatabase();
      Cursor c = db.rawQuery(selectQuery, null);

      if (c.moveToFirst()) {

        ViewItem item = new ViewItem(c.getString(c.getColumnIndex("imageUrl")));
        item.setChapterUrl(c.getString(c.getColumnIndex("chapterUrl")));
        item.setFileUrl(c.getString(c.getColumnIndex("fileUrl")));
        item.setOrder(c.getInt(c.getColumnIndex("stt")));

        return item;
      }
      c.close();
    } catch (Exception e) {

    }
    return null;
  }