bhavin2587
Lurker
Shared Preference Editor is taking a long time to update the value
Shared Preference Editor is taking a long time (3-4 seconds) to update the value into the XML file.
Below is my scenario
- I am updating the parameter value into the shared pref.XML file.
- After updating the value withing 2-3 seconds I reboot the device.
- After reboot I am able to see there is two shared pref XML file in /data/data/apk.package/shared_pref path. one is original and another one is xml.bak file In xml.bak file parameter value is not updated while in xml file value has been updated properly.
- After reboot when I run the application, bak.xml is convert into the main xml file (main xml file deleted) and application read parameter value from bak.xml file which is not correct.
Java:
sUserPref = app.getSharedPreferences("ABC", Context.MODE_PRIVATE);
sUserEditor = sUserPref.edit();
sUserEditor.putInt(storedKey, value);
if (sUserEditor.commit()) {
LogHelper.Logd(DBG_HEADER, "commit success");
return true;
} else {
return false;
}