Exemplo n.º 1
0
  public boolean save() {
    if (myIsSaved) {
      return false;
    }
    final BooksDatabase database = BooksDatabase.Instance();
    database.executeAsATransaction(
        new Runnable() {
          public void run() {
            if (myId >= 0) {
              final FileInfoSet fileInfos = new FileInfoSet(File);
              database.updateBookInfo(myId, fileInfos.getId(File), myEncoding, myLanguage, myTitle);
            } else {
              myId = database.insertBookInfo(File, myEncoding, myLanguage, myTitle);
              storeAllVisitedHyperinks();
            }

            long index = 0;
            database.deleteAllBookAuthors(myId);
            for (Author author : authors()) {
              database.saveBookAuthorInfo(myId, index++, author);
            }
            database.deleteAllBookTags(myId);
            for (Tag tag : tags()) {
              database.saveBookTagInfo(myId, tag);
            }
            database.saveBookSeriesInfo(myId, mySeriesInfo);
          }
        });

    myIsSaved = true;
    return true;
  }