/**
   * Hardcoded example showing how we use everything that has been put together. This will pull down
   * the RSS feed from a specific stream, parse it, then pull down all the images required and store
   * them in the database.
   */
  public void populateDataWithDefaults() {
    try {
      SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
      PicasaHandler picasaHandler = new PicasaHandler();
      URL picasaFeed =
          new URL(
              "http://picasaweb.google.com/data/feed/base/user/c.saunders322/albumid/5513471319225508497?alt=rss&kind=photo&hl=en_US");
      parser.parse(picasaFeed.openStream(), picasaHandler);
      PicasaAlbum album = picasaHandler.getParsedAlbum();
      Log.d(
          "Parser Results:",
          "There are "
              + album.getAlbumImages().size()
              + " images in the "
              + album.getTitle()
              + " album created by "
              + album.getAuthor());

      ImageAlbumDatabaseHelper databaseHelper =
          new ImageAlbumDatabaseHelper(getApplicationContext());
      PicasaAlbumManager albumManager = databaseHelper.getAlbumManager();
      if (!albumManager.albumExists(album.getTitle())) {
        long albumId = albumManager.addAlbum(album);
        if (albumId > 0) {
          Log.d(getClass().toString(), "Successfully added album to the database");
        } else {
          Log.e(
              getClass().toString(),
              "Something went wrong when trying to add new information to disk");
        }
      }
      // Since our data has changed, we need to inform the cursor to update itself
      albumCursorAdapter.getCursor().requery();
    } catch (SAXException saxException) {
      saxException.printStackTrace();
    } catch (MalformedURLException murlException) {
      murlException.printStackTrace();
    } catch (IOException ioe) {
      ioe.printStackTrace();
    } catch (ParserConfigurationException pce) {
      pce.printStackTrace();
    }
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ImageAlbumDatabaseHelper databaseHelper = new ImageAlbumDatabaseHelper(getApplicationContext());
    PicasaAlbumManager albumManager = databaseHelper.getAlbumManager();

    Cursor albumCursor = albumManager.getAlbumCursor();

    // Let the activity manage the cursor so that our cursors get closed
    // when our activity is finished
    startManagingCursor(albumCursor);

    String[] columns = new String[] {PicasaAlbumManager.TITLE, PicasaAlbumManager.AUTHOR};
    int[] names = new int[] {R.id.picasaAlbumTitle, R.id.picasaAlbumAuthor};

    albumCursorAdapter =
        new AlbumCursorAdapter(this, R.layout.picasa_album_row, albumCursor, columns, names);

    ListView albumList = (ListView) findViewById(R.id.picasaAlbumList);
    albumList.setAdapter(albumCursorAdapter);
    albumList.setOnItemClickListener(this);
  }