SharedPreferences value is not updated

后端 未结 5 918
野性不改
野性不改 2020-12-01 18:08

I am trying to update the values of SharedPreferences, here is my code:

edit = PreferenceManager.getDefaultSharedPreferences(this).edit();
e         


        
5条回答
  •  孤街浪徒
    2020-12-01 18:40

    hope it will help you..

    SharedPreferences mypref = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor prefsEditr = mypref.edit();
    prefsEditr.putString("Userid", UserId);
    prefsEditr.commit();
    
    
    String task1 = mypref.getString("Userid", "");
    

提交回复
热议问题