android - How to remove Specific values from Shared Preference -
am using sharedpreferences store list of values. need remove specific value sharedpreferences.below code using remove. not working.
prefs= detailactivity.this.getsharedpreferences("itemfkid",context.mode_private); edit=prefs.edit(); //edit.clear(); edit.remove(itemfkid); edit.commit();
below screenshot contains values after edit.remove() compiles.
here inserting values sharedpreferences
prefs= detailactivity.this.getsharedpreferences("itemfkid",context.mode_private); edit=prefs.edit(); (int = 0; < config.favouriteslist.size(); i++) { edit.putstring("itemfkidvalue" +i, config.favouriteslist.get(i)); } edit.putint("itemfkidlength", config.favouriteslist.size()); edit.commit();
the documentation sharedpreferences.editor
has 2 bits relevant question:
all changes make in editor batched, , not copied original sharedpreferences until call commit() or apply()
and
when committing preferences, removals done first, regardless of whether called remove before or after put methods on editor
so you'll have step on commit()
call before see value removed.
Comments
Post a Comment