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. debugging image

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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -