android - SharedPreferences does not apply() or commit() inside a service with its own process -


i have service has own process:

<service     android:name=".services.commander"     android:label="@string/commander"     android:process=":commander_process" > </service> 

inside service asynctask executed using executeonexecutor. inside onpostexecute method want write data using following code:

sharedpreferences prefs = getsharedpreferences("my_app_key", context.mode_private); prefs.edit().putstring(constants.pref_key_app_password, md5.get(password)).apply(); 

but, code has no effect , prefs won't update. tried commit() rather apply() , didn't work, too. tried mode_multi_process instead of mode_private:

sharedpreferences prefs = getsharedpreferences("my_app_key", context.mode_multi_process); 

it didn't work.

my code works on android 2.3.6, wouldn't work on android 4.2.2. how can fix it?

unfortunately, sharedpreferences not process-safe after using mode_multi_process. ran service same process main activity , works properly. changed code in manifest xml:

<service     android:name=".services.commander"     android:label="@string/commander" > </service> 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -