I am trying to implement a save button that saves shared preferences from several editText inputs.
I am trying to implement a button function that when pressed saves the values from multiple editTexts, into sharedPreference keys. After some research i have set what is in the editText fields as variables, which i will then write into shared preferences.
fun onClick() {
var str = editText2.text.toString()
var dex = editText.text.toString()
var int = editText4.text.toString()
when () {
R.id.button -> {
//add write sharedPreferences
}
}
}
I am getting an expecting an expression error when i try and compile it, in the when brackets.
whenneeds an argument which will be compared to the cases like the caseR.id.button.So you can implement the onClickListener interface like