开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜