SharedPreferences.OnSharedPreferenceChangeListener 用于监听首选项的变化
测试小结论;
我每次写的数值都是1,这个key的值后面没有一直变化,实际不会一直触发onSharedPreferenceChanged
PreferencesUtil.getPreferences().edit().putLong(ExtraName.ORDER_CHANGE, 1).commit();
private SharedPreferences.OnSharedPreferenceChangeListener spChangeListen = new SharedPreferences.OnSharedPreferenceChangeListener() {@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {if (ExtraName.PHONE_NUM.equals(key)) {setUserInfo(); } else if (ExtraName.ORDER_CHANGE.equals(key)) {getUserInfoData(); }} };