/** Update the bookmark screen shot. */
  private void updateBookmarkScreenShot() {

    Cursor c = mDbAdapter.getBookmarkFromUrl(mWebView.getOriginalUrl(), mWebView.getLoadedUrl());

    if ((c != null) && (c.moveToFirst())) {

      long id = c.getLong(c.getColumnIndex(DbAdapter.BOOKMARKS_ROWID));

      Bitmap bm = createScreenshot();

      if (bm != null) {

        mDbAdapter.updateBookmarkThumbnail(id, bm);
      }

      mDbAdapter.updateBookmarkCount(id);
    }

    c.close();
  }
  /**
   * Create a screen shot for the current view.
   *
   * @return A bitmap of the screen shot.
   */
  private Bitmap createScreenshot() {
    Picture thumbnail = mWebView.capturePicture();
    if (thumbnail == null) {
      return null;
    }

    float density = mContext.getResources().getDisplayMetrics().density;

    int thumbnailWidth = (int) (Constants.BOOKMARK_THUMBNAIL_WIDTH_FACTOR * density);
    int thumbnailHeight = (int) (Constants.BOOKMARK_THUMBNAIL_HEIGHT_FACTOR * density);

    Bitmap bm = Bitmap.createBitmap(thumbnailWidth, thumbnailHeight, Bitmap.Config.ARGB_4444);

    Canvas canvas = new Canvas(bm);

    if (thumbnail.getWidth() > 0) {
      float scaleFactor = (float) thumbnailWidth / (float) thumbnail.getWidth();
      canvas.scale(scaleFactor, scaleFactor);
    }

    thumbnail.draw(canvas);
    return bm;
  }