Java tutorial
//package com.java2s; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; public class Main { public static final String PREF_NAME = "weather"; public static final String PREF_AUTO_REFRESH = "auto_refresh"; public static void saveAutoRefreshToPreference(Context c, boolean autoRefresh) { SharedPreferences preferences = c.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); Editor editor = preferences.edit(); editor.putBoolean(PREF_AUTO_REFRESH, autoRefresh); editor.apply(); } }