Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; public class Main { private static final String SP_NAME = "souyue"; public static final String KEY_CITY = "KEY_CITY"; public static String getCity(Context context) { SharedPreferences sp = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); if (sp != null) { return sp.getString(KEY_CITY, "null"); } return ""; } }