android-jetpack-composecompose-desktop

How to store data in Jetpack Compose Desktop?


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


Solution

  • 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.