/** 处理服务端返回的县级json数据 */ public static synchronized boolean handleCountiesResponse( WeatherDB weatherDB, String response, City city) { if (!TextUtils.isEmpty(response)) { String[] allCounties = response.split(","); if (allCounties != null && allCounties.length > 0) { for (String c : allCounties) { String[] array = c.split("\\|"); County county = new County(); county.setCounty_code(array[0]); county.setCounty_name(array[1]); county.setCity(city); weatherDB.saveCounty(county); } return true; } } return false; }
/** 处理服务端返回的省级json数据 */ public static synchronized boolean handleProvicesResponse(WeatherDB weatherDB, String response) { if (!TextUtils.isEmpty(response)) { String[] allProvices = response.split(","); if (allProvices != null && allProvices.length > 0) { for (String p : allProvices) { String[] array = p.split("\\|"); Province province = new Province(); province.setProvince_code(array[0]); province.setProvince_name(array[1]); weatherDB.saveProvice(province); } return true; } } return false; }