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

后端 未结 6 1182
梦如初夏
梦如初夏 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:27

    if you have a checkbox and you would like to fetch it's value ie true / false in any java file--

    Use--

    Context mContext;
    boolean checkFlag;
    
    checkFlag=PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(KEY,DEFAULT_VALUE);`
    

提交回复
热议问题