Exemplo n.º 1
0
 /** 解析和处理服务器返回的省级数据 */
 public static synchronized boolean handleProvincesResponse(
     CoolWeatherDB coolWeatherDB, String response) {
   if (!TextUtils.isEmpty(response)) {
     String[] allProvinces = response.split(",");
     if (allProvinces != null && allProvinces.length > 0) {
       for (String p : allProvinces) {
         String[] array = p.split("\\|");
         Province province = new Province();
         province.setProvinceCode(array[0]);
         province.setProvinceName(array[1]);
         // 将解析出来的数据存储到Province表
         coolWeatherDB.saveProvince(province);
       }
       return true;
     }
   }
   return false;
 }
Exemplo n.º 2
0
 /** 解析和处理服务器返回的县级数据 */
 public static synchronized boolean handleCountiesResponse(
     CoolWeatherDB coolWeatherDB, String response, int cityId) {
   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.setCountyCode(array[0]);
         county.setCountyName(array[1]);
         county.setCityId(cityId);
         // 将解析出来的数据存储到County表
         coolWeatherDB.saveCounty(county);
       }
       return true;
     }
   }
   return false;
 }