I am currently trying to make a TextView show whatever date my TimePicker returns. It works, but if I go into another fragment and back, restart the app, etc, the text reverts to the default I set. Does anyone know how I could make the text I'm setting persistent? Here is the code that I am using.
view.timeButton.setOnClickListener {
            val cal = Calendar.getInstance()
            val timeSetListener = TimePickerDialog.OnTimeSetListener { timePicker, hour, minute ->
                cal.set(Calendar.HOUR_OF_DAY, hour)
                cal.set(Calendar.MINUTE, minute)
                alarmText.text = ("Texts at " + SimpleDateFormat("HH:mm").format(cal.time))
            }
            TimePickerDialog(
                context,
                timeSetListener,
                cal.get(Calendar.HOUR_OF_DAY),
                cal.get(Calendar.MINUTE),
                false
            ).show()
        }
 
    