The key values you pass to save and retrieve your data in sharedpreferences are identical… each is an empty string
“”
const val UNIT = ""
const val VOLUME = ""
const val HEIGHT = ""
const val CALCULATION = ""
Each key must be unique and contain an actual string value that can be retrieved against:
const val UNIT = "UNIT"
const val VOLUME = "VOLUME"
const val HEIGHT = "HEIGHT"
const val CALCULATION = "CALCULATION"
Since the values retrieved are integers not strings then why not store them as integers?
pref.getInt(UNIT, 0)
editor.putInt(UNIT, outputUnit.text.toString().toInt())
CLICK HERE to find out more related problems solutions.