@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.choose_area);
    listView = (ListView) findViewById(R.id.list_view);
    titleText = (TextView) findViewById(R.id.title_text);
    adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, dataList);
    listView.setAdapter(adapter);
    coolWeatherDB = CoolWeatherDB.getInstance(this);

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (currentLevel == LEVEL_PROVINCE) {
              selectedProvince = provinceList.get(position);
              queryCities();
            } else if (currentLevel == LEVEL_CITY) {
              selectedCity = cityList.get(position);
              queryCounties();
            }
          }
        });
    queryProvinces();
  }
 private void queryCities() {
   cityList = coolWeatherDB.loadCites(selectedProvince.getId());
   if (cityList.size() > 0) {
     dataList.clear();
     for (City city : cityList) {
       dataList.add(city.getCityName());
     }
     adapter.notifyDataSetChanged();
     listView.setSelection(0);
     titleText.setText(selectedProvince.getProvinceName());
     currentLevel = LEVEL_CITY;
   } else {
     queryFromServer(selectedProvince.getProvinceCode(), "city");
   }
 }
 private void queryProvinces() {
   provinceList = coolWeatherDB.loadProvinces();
   if (provinceList.size() > 0) {
     dataList.clear();
     for (Province province : provinceList) {
       dataList.add(province.getProvinceName());
     }
     adapter.notifyDataSetChanged();
     listView.setSelection(0);
     titleText.setText("中国");
     currentLevel = LEVEL_PROVINCE;
   } else {
     queryFromServer(null, "province");
   }
 }