Change text in editpreference by code
Hi I have an edit preference and I want to change the value stored in it by code, is t开发者_StackOverflow社区his possible?
I tried this but it didn't work
String input1 = hello;
prefs.getString("location", "").replace(prefs.getString("location", ""), input1);
prefs.edit().putString("location", MODIFIED_STRING_HERE).commit();
You should use the put* method and then commit it to the shared preferences. Refer to this example
To update the text within your editText, use the setText method, refer to the manpages
精彩评论