Java tutorial
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; public class Main { private static void saveWeatherInfo(Context context, String city, String cityid, String temp1, String temp2, String weather, String ptime) { SimpleDateFormat format = new SimpleDateFormat("yyyy-M-d", Locale.CHINA); SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(context).edit(); edit.putBoolean("city_selected", true); edit.putString("city", city); edit.putString("cityid", cityid); edit.putString("temp1", temp1); edit.putString("temp2", temp2); edit.putString("weather", weather); edit.putString("ptime", ptime); edit.putString("ctime", format.format(new Date())); edit.commit(); } }