Ejemplo n.º 1
0
  // Gets Todays Verse
  public MorningWatchBO getTodayVerse() {
    SQLiteDatabase db = this.getReadableDatabase();
    // Gets the verse for today
    Cursor cursor =
        db.query(
            tableName,
            new String[] {"BibleVerse", "Description", "Url", "Entry_Date", "Favourites"},
            "Entry_Date" + "='" + getTodayDate() + "'",
            null,
            null,
            null,
            null,
            null);

    MorningWatchBO morningWatchBO = new MorningWatchBO();

    if (cursor != null) cursor.moveToFirst();

    System.err.println("CURSOR SIZE " + cursor.getCount());

    if (cursor.getCount() > 0) {

      morningWatchBO.setTitle(cursor.getString(0));
      morningWatchBO.setDescription(cursor.getString(1));
      morningWatchBO.setLink(cursor.getString(2));
      morningWatchBO.setDate(cursor.getString(3));
      morningWatchBO.setFavourite(cursor.getString(4));
    }
    return morningWatchBO;
  }
Ejemplo n.º 2
0
  // Getting all verses
  public List<MorningWatchBO> getAllVersesForWeek() {
    List<MorningWatchBO> verses = new ArrayList<MorningWatchBO>();
    SQLiteDatabase db = this.getReadableDatabase();
    // Returns all verses for the week
    // String query = "Select * from " +tableName+" where Entry_Date >= (select
    // strftime('%Y-%m-%d',datetime('now','-1 day' ))) ORDER BY Entry_Date ASC";
    Cursor cursor =
        db.query(
            tableName,
            null,
            "Entry_Date >= (select strftime('%Y-%m-%d',datetime('now','-7 day' )))",
            null,
            null,
            null,
            "Entry_Date ASC");
    // Cursor  cursor = db.query(tableName, null, null, null, null, null, null);
    // Cursor  cursor = db.rawQuery(query,null);

    // looping through all rows and adding to list
    if (cursor.moveToFirst()) {
      do {
        MorningWatchBO morningWatchBO = new MorningWatchBO();

        morningWatchBO.setTitle(cursor.getString(1));
        morningWatchBO.setDescription(cursor.getString(2));
        morningWatchBO.setLink(cursor.getString(3));
        morningWatchBO.setDate(cursor.getString(4));
        morningWatchBO.setFavourite(cursor.getString(5));

        // Adding verses to list
        verses.add(morningWatchBO);
      } while (cursor.moveToNext());
    }
    return verses;
  }
Ejemplo n.º 3
0
  // Getting all favourite verses
  public List<MorningWatchBO> getFavouriteVerses() {
    List<MorningWatchBO> verses = new ArrayList<MorningWatchBO>();
    SQLiteDatabase db = this.getReadableDatabase();
    String query = "SELECT  * FROM " + tableName + " where Favourites = 'Y'";
    Cursor cursor = db.rawQuery(query, null);

    // looping through all rows and adding to list
    if (cursor.moveToFirst()) {
      do {
        MorningWatchBO morningWatchBO = new MorningWatchBO();

        morningWatchBO.setTitle(cursor.getString(1));
        morningWatchBO.setDescription(cursor.getString(2));
        morningWatchBO.setLink(cursor.getString(3));
        morningWatchBO.setDate(cursor.getString(4));
        morningWatchBO.setFavourite(cursor.getString(5));

        // Adding verses to list
        verses.add(morningWatchBO);
      } while (cursor.moveToNext());
    }
    return verses;
  }