コード例 #1
0
 public synchronized void saveArea(Area area) {
   if (mSharePreference != null && area != null) {
     Editor editor = mSharePreference.edit();
     editor.putString(AREA_ID, area.getmId());
     editor.putString(AREA_NAME, area.getmName());
     editor.commit();
   }
 }
コード例 #2
0
 public synchronized Area getArea() {
   if (mSharePreference != null) {
     String id = mSharePreference.getString(AREA_ID, null);
     String name = mSharePreference.getString(AREA_NAME, null);
     if (!TextUtils.isEmpty(id)) {
       Area area = new Area();
       area.setmId(id);
       area.setmName(name);
       return area;
     } else {
       Area area = new Area();
       area.setmId("1");
       area.setmName("安徽");
       return area;
     }
   }
   return null;
 }