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. 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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.