Android SharedPreferences Save setSharedPreferences(String key, String value, Context context)

Here you can find the source of setSharedPreferences(String key, String value, Context context)

Description

set Shared Preferences

Declaration

public static void setSharedPreferences(String key, String value,
            Context context) 

Method Source Code

//package com.java2s;

import android.content.Context;
import android.content.SharedPreferences;

import android.preference.PreferenceManager;

public class Main {
    public static void setSharedPreferences(String key, String value,
            Context context) {/* ww w  . j  a v  a 2s .  c  o m*/
        SharedPreferences prefs = PreferenceManager
                .getDefaultSharedPreferences(context);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString(key, value);
        editor.commit();
    }
}

Related

  1. putPrefs(Activity context, int mode, Map pairs)
  2. putSharedPrefs(Context context, String prefName, int mode, Map pairs)
  3. saveSetting(Context context, String name, Long value)
  4. saveSetting(Context context, String name, String value)
  5. updatePrefValueByModel(SharedPreferences pref, String key, String thisModel, String targetModel, Object targetModelValue, Object notTargetModelValue)
  6. putPrefBoolean(Context c, String key, boolean value)
  7. putPrefInt(Context c, String key, int value)