[英]How can i change value ListPreference from another Activity
I have Activity for ListPreference and i can change any values in it, but my question i want to change a value in ListPreference first time without the user enters to activity that there is ListPreference.我有 ListPreference 的活动,我可以更改其中的任何值,但我的问题是我想在没有用户进入存在 ListPreference 的活动的情况下第一次更改 ListPreference 中的值。 First time a user enters to an app i want to save default value depend on location the user.
用户第一次进入应用程序时,我想保存默认值取决于用户的位置。
I found the solution我找到了解决方案
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(getString(R.string.settings_method_key),repear);
editor.commit();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.