android - SharedPreferences.Editor not being updated after initial commit -



android - SharedPreferences.Editor not being updated after initial commit -

i'ma bit confused here. i'm trying alter value of edittextpreference, not updated in view. (this in preferenceactivity)

here code:

@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); addpreferencesfromresource(r.xml.modify_instrument_preferences); // set default values sharedpreferences customsharedpreference = preferencemanager.getdefaultsharedpreferences(this); sharedpreferences.editor editor = customsharedpreference.edit(); modifying = getobjectwithname(); //some object name; editor.putstring("namepref", modifying.getname()); editor.commit(); android.util.log.d("test", "written: "+customsharedpreference.getstring("namepref","")); }

my printlns print out valid information, , commit() returns true, on clicking edittextpreference, displays old value. if rotate screen, causing oncreate run again, edittextpreference has right value.

so perplexing. why isn't alter beingness updated in ui?

edit:

i'm not sure why above isn't working, managed alter doing:

edittextpreference namepref = (edittextpreference) findpreference("namepref"); namepref.settext("the text");

that updated view everytime.

although know there constructs in place preferenceactivities maintain track of info themselves, doesn't seem documented. have found adding onpreferencechangelistener preference allow create edits preference changed.

android sharedpreferences preferenceactivity

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -