Android examples for android.content:SharedPreferences
save Preference
import android.content.Context; import android.content.SharedPreferences; public class Main { /**//from w w w.j a v a 2 s . co m * Method savePreference ... * * @param paramContext * of type Context * @param paramString1 * of type String * @param paramString2 * of type String */ public static void savePreference(Context paramContext, String paramString1, String paramString2) { SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("com.java2s.client", 0).edit(); localEditor.putString(paramString1, paramString2); localEditor.commit(); } /** * Method savePreference ... * * @param paramContext * of type Context * @param paramString1 * of type String * @param paramString2 * of type int */ public static void savePreference(Context paramContext, String paramString1, int paramString2) { SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("com.java2s.client", 0).edit(); localEditor.putInt(paramString1, paramString2); localEditor.commit(); } }