Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; public class Main { /** * Called to save supplied value in shared preferences against given key. * * @param context Context of caller activity * @param key Key of value to save against * @param value Value to save */ public static void saveToPrefs(Context context, String key, String value) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences.Editor editor = prefs.edit(); editor.putString(key, value); editor.commit(); } }