private ArrayList<String> getAllCities() { ArrayList<City> cities = cityDB.getAllCity(); ArrayList<String> ret = new ArrayList<String>(); for (City city : cities) { ret.add(city.getCity()); } return ret; }
private ArrayList<String> getAllProvinces() { ArrayList<String> provinces = new ArrayList<String>(); ArrayList<City> cities = cityDB.getAllCity(); for (City city : cities) { String provinceName = city.getProvince(); if (!provinces.contains(provinceName)) provinces.add(provinceName); } return provinces; }
public void changeCity(String cityName) { mAddressCityNameHan = cityName; setCurrentTitle_City(mAddressCityNameHan, 1.0f); mAdminArea = cityDB.getCityProvince(mAddressCityNameHan).getProvince(); try { refreshableView.RefreshByHand(); } catch (Exception e) { e.printStackTrace(); Log.d("Lesshst, error: ", e.toString()); } }
private void getWeatherInfoFromXML() { mAddressCityNameHan = citiesList.get(currentIndex); try { GetWeatherInfo getweatherInfo = new GetWeatherInfo(); String cityCode = cityDB.getCity(mAddressCityNameHan).getCityNumber(); getweatherInfo.queryWeatherCode(cityCode, mainHandler); } catch (Exception e) { e.printStackTrace(); Log.d("Lesshst, error: ", e.toString()); } }
public CityDB openCityDB() { String dbDicPath = "/data" + Environment.getDataDirectory().getAbsolutePath() + File.separator + getPackageName() + File.separator + "databases"; String path = dbDicPath + File.separator + CityDB.CITY_DB_NAME; File db = new File(path); File dbDic = new File(dbDicPath); if (db.exists()) db.delete(); Log.d("Lesshst, cityDBPath", path); if (!db.exists()) { Log.i("", "db is not exists"); try { if (!dbDic.exists()) { dbDic.mkdirs(); } if (!db.exists()) db.createNewFile(); InputStream is = getAssets().open("city.db"); FileOutputStream fos = new FileOutputStream(db); int len = -1; byte[] buffer = new byte[1024]; while ((len = is.read(buffer)) != -1) { fos.write(buffer, 0, len); fos.flush(); } fos.close(); is.close(); } catch (IOException e) { e.printStackTrace(); Log.d("Lesshst, error:", e.toString()); System.exit(0); } } cityDB = new CityDB(this, path); Log.d("Lesshst: cityNumber", cityDB.getCity("石景山").getCityNumber()); return cityDB; }