Beispiel #1
0
 /** Return one card starting from the given cursor. */
 private static Card oneFromCursor(Cursor cursor) {
   if (cursor.isClosed()) {
     throw new SQLException();
   }
   cursor.moveToFirst();
   Card card = new Card();
   card.id = cursor.getLong(0);
   card.interval = cursor.getDouble(1);
   card.question = cursor.getString(2);
   card.answer = cursor.getString(3);
   return card;
 }
Beispiel #2
0
  // TODO: The real methods to update cards on Anki should be implemented instead of this
  public void updateAllCards() {
    Cursor cursor = AnkiDb.database.rawQuery("SELECT id, factId " + "FROM cards", null);

    while (cursor.moveToNext()) {
      // Get card
      Card card = new Card();
      card.fromDB(cursor.getLong(0));
      Log.i(TAG, "Card id = " + card.id);

      // Get the related fact
      Fact fact = card.getFact();
      // Log.i(TAG, "Fact id = " + fact.id);

      // Generate the question and answer for this card and update it
      HashMap<String, String> newQA = CardModel.formatQA(fact, card.getCardModel());
      card.question = newQA.get("question");
      Log.i(TAG, "Question = " + card.question);
      card.answer = newQA.get("answer");
      Log.i(TAG, "Answer = " + card.answer);
      card.modified = System.currentTimeMillis() / 1000.0;

      card.toDB();
    }
  }