6

I am creating an application in Jetpack Compose Desktop which will take user input and after user reopens the application that input value should be there. I mean a user given data should be there after user reopens the application.

remember { mutableStateOf } doesn't work here

I didn't get tag for jetpack compose desktop so I have android Jetpack Compose tag

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220

2 Answers2

5

The remember will only save data while the current view is visible on the screen. Check out more about state it compose in documentation.

If you need to save something between application runs, you need to save it to a database or write it to a file and read it when the application runs.

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
3

One way of doing this is to use the Java Preference API to store Key/Value based values.

If you need more complicated data, you would need to store your data into a File or a database.

Alex Styl
  • 3,982
  • 2
  • 28
  • 47