1/* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.deskclock.worldclock; 18 19import android.content.SharedPreferences; 20 21public class CityObj { 22 23 private static final String CITY_NAME = "city_name_"; 24 private static final String CITY_TIME_ZONE = "city_tz_"; 25 private static final String CITY_ID = "city_id_"; 26 27 public String mCityName; 28 public String mTimeZone; 29 public String mCityId; 30 31 public CityObj(String name, String timezone, String id) { 32 mCityName = name; 33 mTimeZone = timezone; 34 mCityId = id; 35 } 36 37 @Override 38 public String toString() { 39 return "CityObj{" + 40 "name=" + mCityName + 41 ", timezone=" + mTimeZone + 42 ", id=" + mCityId + 43 '}'; 44 } 45 46 47 public CityObj(SharedPreferences prefs, int index) { 48 mCityName = prefs.getString(CITY_NAME + index, null); 49 mTimeZone = prefs.getString(CITY_TIME_ZONE + index, null); 50 mCityId = prefs.getString(CITY_ID + index, null); 51 } 52 53 public void saveCityToSharedPrefs(SharedPreferences.Editor editor, int index) { 54 editor.putString (CITY_NAME + index, mCityName); 55 editor.putString (CITY_TIME_ZONE + index, mTimeZone); 56 editor.putString (CITY_ID + index, mCityId); 57 } 58 59} 60