SharedPreferences Editor team takes so long

I am trying to do configuration activity using PreferenceActivity ...

I found some working examples, for example

WiFi Advanced Configuration Editor

and

"Wifi Config Editor Pro"

but the code I wrote is waiting 10-15 seconds on the editor.commit () line ... it should be very simple, but I can not understand.

here is a short code;

...

SharedPreferences prefs = PreferenceManager
                .getDefaultSharedPreferences(v.getContext());
prefs.registerOnSharedPreferenceChangeListener(ClassConfig.this);

    SharedPreferences.Editor editor = prefs.edit();
editor.clear();

editor.putString("key1", value1);
editor.putString("key2", value2);
editor.putBoolean("key3", value3);
    ...
    //i got nearly 35 keys here
    ...
    editor.putString("key33", value33);
editor.putBoolean("key34", value34);
editor.putBoolean("key35", value35);

    editor.commit();

any ideas

Update: one more thing. I saw these warnings in a log file

W / BackupManagerService (1914) dataChanged but not PKG member = 'com.android.providers.settings' UID = 10046

+3
source share
4 answers

commit() , , . apply().

fooobar.com/questions/21215/...

+3

- . AsyncTask

+2

apply(), . . Docs

+2

? OnSharedPreferenceChanged?

PreferenceActivity, , , XML PreferenceActivity.

0

Source: https://habr.com/ru/post/1789939/


All Articles