SHARE
TWEET

Untitled

a guest Jun 25th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  private static SharedPreferences mSharedPref;
  2.      private static  final String KEYNAME = "nombre";
  3.      
  4.      private  private static SharedPreferences mSharedPref;
  5.      private static  final String KEYNAME = "nombre";
  6.      
  7.      private MySharedPreferences(){
  8.          
  9.      }
  10.      
  11.      public static  void init(Context context){
  12.          if(mSharedPref == null)
  13.              mSharedPref = context.getSharedPreferences("MYPREFS", Activity.MODE_PRIVATE);
  14.      }
  15.      
  16.      public static void saveName(String name){
  17.          SharedPreferences.Editor prefsEditor = mSharedPref.edit();
  18.          prefsEditor.putString(KEYNAME, name);
  19.          prefsEditor.apply();
  20.      }
  21.      public static String loadName(){
  22.          return mSharedPref.getString(KEYNAME, "");
  23.      }
  24.      MySharedPreferences(){
  25.          
  26.      }
  27.      
  28.      public static  void init(Context context){
  29.          if(mSharedPref == null)
  30.              mSharedPref = context.getSharedPreferences("MYPREFS", Activity.MODE_PRIVATE);
  31.      }
  32.      
  33.      public static void saveName(String name){
  34.          SharedPreferences.Editor prefsEditor = mSharedPref.edit();
  35.          prefsEditor.putString(KEYNAME, name);
  36.          prefsEditor.apply();
  37.      }
  38.      public static String loadName(){
  39.          return mSharedPref.getString(KEYNAME, "");
  40.      }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top