Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; public class Main { private static String HORSEPUSH = "HorsePush"; public static void setSharedPreferences(Context context, String key, String value) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = preferences.edit(); editor.putString(HORSEPUSH + key, value); editor.commit(); } }