private void addAllCategoriesToBookmarked(Category category) {
    List<Category> categories =
        BjcpDataHelper.getInstance(getActivity()).getCategoriesByParent(category.getId());

    for (Category cat : categories) {
      cat.setBookmarked(true);
    }

    BjcpDataHelper.getInstance(getActivity()).updateCategoriesBookmarked(categories);
    Toast.makeText(
            getActivity().getApplicationContext(), R.string.on_tap_success, Toast.LENGTH_SHORT)
        .show();
  }
  private void setupCategoryListView(View view) {
    ListAdapter categoryAdapter =
        new CategoriesListAdapter(
            getActivity(), BjcpDataHelper.getInstance(getActivity()).getAllCategories());
    ListView categoryListView = (ListView) view.findViewById(R.id.categoryListView);
    categoryListView.setAdapter(categoryAdapter);

    categoryListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (parent.getItemAtPosition(position) instanceof Category) {
              Category category = (Category) parent.getItemAtPosition(position);
              BjcpController.loadCategoryList((Activity) view.getContext(), category);
            }
          }
        });

    categoryListView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            boolean consumed = false;

            if (parent.getItemAtPosition(position) instanceof Category) {
              addAllCategoriesToBookmarked((Category) parent.getItemAtPosition(position));
              consumed = true;
            }

            return consumed;
          }
        });
  }
 @Override
 public void onStop() {
   super.onStop();
   BjcpDataHelper.getInstance(getActivity()).close();
 }