Search code examples
androidpreferences

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 this possible?

I tried this but it didn't work

String input1 = hello;
prefs.getString("location", "").replace(prefs.getString("location", ""), input1);

Solution

  • prefs.edit().putString("location", MODIFIED_STRING_HERE).commit();