Example #1
0
 public void saveProvince(Province province) {
   if (province != null) {
     ContentValues values = new ContentValues();
     values.put("province_name", province.getProvinceName());
     values.put("province_code", province.getProvinceCode());
     db.insert("Province", null, values);
   }
 }
Example #2
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());
   }
   if (cursor != null) {
     cursor.close();
   }
   return list;
 }