I know this question already have tons of answer in SO but I haven't found the answer to my problem.
Here is my code:
SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(Config.SHARED_PREF_NAME, Context.MODE_PRIVATE);
//Creating editor to store values to shared preferences
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.clear();
//Adding values to editor
editor.putBoolean(Config.LOGGEDIN_SHARED_PREF, true);
editor.putString(Config.PHONE_SHARED_PREF, phoneNo);
Log.d("debug", "config "+Config.PHONE_SHARED_PREF);
Log.d("debug", "config "+phoneNo);
//Saving values to editor
editor.apply();
editor.commit();
What I understand is, editor.putString(Config.PHONE_SHARED_PREF, phoneNo) means save the value of phoneNo into PHONE_SHARED_PREF. Please correct me if I'm wrong.
But when in Log, Config.PHONE_SHARED_PREF printed the default value, instead of the new value assigned in phoneNo. That's mean the value of phoneNo not correctly saved, no?
Can someone explain to me what's wrong with my code? :/
 
     
    