C__
C__

Reputation: 63

Which way of saving user data should I use for my Android app?

I'm trying to save the state of the app so that when the user reopens it, it looks just as it did when it was closed.

(I think) I've found at least five ways of doing this:

I'm a bit lost as to which one of these is the correct solution for a given scenario. My app contains several settings, such as whether certain UI elements should be shown or hidden. But it also contains hundreds of objects that reference each other in unique ways based on user behavior. Which way of saving this data should I be using to preserve all of this?

Upvotes: 2

Views: 43

Answers (1)

kronshtatov
kronshtatov

Reputation: 161

If you're using Google's MVVM you can try to use SavedState for ViewModel This way your app state can survive death of the app process. But the state must be lightweight. If you have quite a lot of data on your screen you should also use Room or file cache or something else. You can read about saving states here

Upvotes: 3

Related Questions