开发者

Change text in editpreference by code

开发者 https://www.devze.com 2023-03-10 13:25 出处:网络
Hi I have an edit preference and I want to change the value stored in it by code, is t开发者_StackOverflow社区his possible?

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

精彩评论

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