Esempio n. 1
0
 public List<Province> loadProvinces() {
   List<Province> list = new ArrayList<Province>();
   Cursor cursor = db.query("Province", null, null, null, null, null, null);
   if (cursor.moveToFirst()) {
     do {
       Province province = new Province();
       province.setId(cursor.getInt(cursor.getColumnIndex("id")));
       province.setProvinceName(cursor.getString(cursor.getColumnIndex("province_name")));
       province.setProvinceCode(cursor.getString(cursor.getColumnIndex("province_code")));
       list.add(province);
     } while (cursor.moveToNext());
   }
   return list;
 }
Esempio n. 2
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]);
         coolWeatherDB.saveProvince(province);
       }
       return true;
     }
   }
   return false;
 }