How do I get the SharedPreferences from a PreferenceActivity in Android?

后端 未结 6 1152
梦如初夏
梦如初夏 2020-11-22 11:28

I am using a PreferenceActivity to show some settings for my application. I am inflating the settings via a xml file so that my onCreate (and complete class methods) looks l

6条回答
  •  情深已故
    2020-11-22 12:32

    Try following source code it worked for me

    //Fetching id from shared preferences
        SharedPreferences sharedPreferences;
        sharedPreferences =getSharedPreferences(Constant.SHARED_PREF_NAME, Context.MODE_PRIVATE);
        getUserLogin = sharedPreferences.getString(Constant.ID_SHARED_PREF, "");
    

提交回复
热议问题