/**
   * fills the list with stops from the local database
   *
   * @param db the database adapter to use
   */
  private void fillList(BusDbAdapter db) {
    Cursor c;
    if (listType == FAVORITES) {
      c = db.getFavoriteDest(NUM_ENTRIES_TO_FETCH);
    } else { // listType == MAJOR
      c = db.getMajorDest(NUM_ENTRIES_TO_FETCH);
    }
    int stopIDIndex = c.getColumnIndex("stop_id");
    int stopDescIndex = c.getColumnIndex("stop_desc");
    int routeIDIndex = c.getColumnIndex("route_id");
    int routeDescIndex = c.getColumnIndex("route_desc");
    if (c != null) {
      for (int i = 0; i < c.getCount(); i++) {
        HashMap<String, String> item = new HashMap<String, String>();

        String stopID = c.getString(stopIDIndex);
        String stopName = c.getString(stopDescIndex);
        String route = c.getString(routeIDIndex);
        String routeDesc = c.getString(routeDescIndex);
        Log.v(TAG, "PUT");
        Log.v(TAG, "stopID " + stopID + " stopName " + stopName);
        Log.v(TAG, "routeID " + route + " routeDesc" + routeDesc);
        item.put("stopID", stopID);
        item.put("stopName", stopName);
        item.put("routeID", route);
        item.put("routeDesc", routeDesc);
        c.moveToNext();
        locationList.add(item);
      }
      listAdapter.notifyDataSetChanged();
    }
  }
  /** actions for the context menu */
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    int id = (int) getListAdapter().getItemId(info.position);

    // sets an alarm for the selected stop
    switch (item.getItemId()) {
      case SET_STOP_OPTION:
        Intent i = new Intent(getApplicationContext(), ConfirmationPage.class);
        HashMap<String, String> busItem = locationList.get(id);
        DataFetcher df = new DataFetcher();
        try {
          BusStop b = df.getStopById(Integer.parseInt(busItem.get("stopID").split("_")[1]));
          i.putExtra("busstop", b);
          i.putExtra("busroute", busItem.get("routeID"));
          i.putExtra("busroutedesc", busItem.get("routeDesc"));
          startActivity(i);
          finish();
          // if an exception occurs, nothing happens (for now).
        } catch (NumberFormatException e) {
          Log.v(TAG, "Error parsing stop id!");
          e.printStackTrace();
        } catch (IOException e) {
          Log.v(TAG, "Error fetching info!");
          e.printStackTrace();
        }
        break;
        // removes the selected stop from the list
      case REMOVE_STOP_OPTION:
        HashMap<String, String> itemToRemove = locationList.get(id);
        mBusDbHelper.open();
        mBusDbHelper.deleteDest(itemToRemove.get("routeID"), itemToRemove.get("stopID"));
        mBusDbHelper.close();
        locationList.remove(id);
        listAdapter.notifyDataSetChanged();
        break;
      case CANCEL:
        break;
      default:
        break;
    }
    return true;
  }