Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; public class Main { public static final String STATE_LOGIN = "state_login"; public static void setLoginState(Context context, boolean isLogin) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(STATE_LOGIN, isLogin); editor.commit(); } }