2

I have an activity with 4 fragments, on each of the fragments the user inputs a string and then moves on to the next one. So far I have a viewModel for every fragment and I pass each input as an argument that then I store in the viewModel.

My question is, should I just have a single viewModel where I store all of this inputs? Or is ok this way? Is there a better solution?

Jose Gonzalez
  • 1,491
  • 3
  • 25
  • 51

1 Answers1

2

If the viewmodels serve only the purpose of storing the data, you could create a shared view model in the activity and use it in all of the fragments, this way you can access any variable in all the fragments.