In my android service I have action user present registered which writes a String value to default shared preference. Meanwhile I have another function in the service which writes a Hashset to shared preference. I have used commit in both cases.
On user present action :
PreferenceManager.getDefaultSharedPreferences(getBaseContext()).edit().putString("abc", udata).commit();
On onother function :
if(PreferenceManager.getDefaultSharedPreferences(getBaseContext()).edit().putStringSet("si",ssetdata).commit())
Some times second writing fails why ? Is it because
"Note that when two editors are modifying preferences at the same time, the last one to call commit wins. "