public void saveCounty(County county) {
   if (county != null) {
     ContentValues values = new ContentValues();
     values.put("county_name", county.getCountyName());
     values.put("county_code", county.getCountyCode());
     values.put("city_id", county.getCityId());
     db.insert("County", null, values);
   }
 }
 private void queryCounties() {
   countyList = coolWeatherDB.loadCounties(selectedCity.getId());
   if (countyList.size() > 0) {
     dataList.clear();
     for (County county : countyList) {
       dataList.add(county.getCountyName());
     }
     adapter.notifyDataSetChanged();
     listView.setSelection(0);
     titleText.setText(selectedCity.getCityName());
     currentLevel = LEVEL_COUNTY;
   } else {
     queryFromServer(selectedCity.getCityCode(), "county");
   }
 }
 public List<County> loadCounties(int cityId) {
   List<County> list = new ArrayList<>();
   Cursor cursor =
       db.query(
           "County", null, "city_id = ?", new String[] {String.valueOf(cityId)}, null, null, null);
   if (cursor.moveToFirst()) {
     do {
       County county = new County();
       county.setId(cursor.getInt(cursor.getColumnIndex("id")));
       county.setCountyName(cursor.getString(cursor.getColumnIndex("county_name")));
       county.setCountyCode(cursor.getString(cursor.getColumnIndex("county_code")));
       county.setCityId(cursor.getInt(cursor.getColumnIndex("city_id")));
       list.add(county);
     } while (cursor.moveToNext());
   }
   return list;
 }