Mega Code Archive

 
Categories / Android / Security
 

Save value to SharedPreferences

import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; /** Collection of general purpose functions  * @author johngraves  *  */ class Library {   // ---------------------   /** Update shared preferences from State */   public static void savePreferences(Context context) {     SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());     SharedPreferences.Editor editor = prefs.edit();     editor.putBoolean("silentMode", true);     editor.putString("language", "State.getLanguage()");     editor.commit();   } }