public void parse(
      String filename,
      String filenameAlias,
      String checksum,
      BufferedReader breader,
      Context context) {
    this.useTitleField =
        PreferenceManager.getDefaultSharedPreferences(context).getBoolean("useAgendaTitle", false);

    this.file_id = addNewFile(filename, filenameAlias, checksum, true);

    this.todos = db.getGroupedTodos();

    this.starStack = new Stack<Integer>();
    this.parentIdStack = new Stack<Long>();

    this.starStack.push(0);
    Long fileID = db.getFileId(filename);
    this.parentIdStack.push(fileID);

    this.payload = new StringBuilder();

    db.getDB().beginTransaction();

    try {
      String currentLine;

      while ((currentLine = breader.readLine()) != null) {

        if (TextUtils.isEmpty(currentLine)) continue;

        int lineLength = currentLine.length();
        int numstars = numberOfStars(currentLine, lineLength);
        if (numstars > 0) {
          parseHeading(currentLine, numstars);
        } else {
          payload.append(currentLine);
          payload.append("\n");
        }
      }

      // Add payload to the final node
      db.addNodePayload(this.parentIdStack.peek(), this.payload.toString());

    } catch (IOException e) {
    }

    if (filename.equals("agendas.org")
        && PreferenceManager.getDefaultSharedPreferences(context)
            .getBoolean("combineBlockAgendas", false)
        && useTitleField) {
      combineBlockAgendas();
    }

    db.getDB().setTransactionSuccessful();
    db.getDB().endTransaction();

    updateCalendar(filename, context);
  }