0

I have an ViewPager with 4 fragments, at the last fragment I want to make a validation and save the values that was inserted in the previous fragments.

I tried to override the onSaveInstanceState and save a Bunble with the data but the method not getting a call (only when the screen goes off).

How can I save the data and access it from the parent activity?

Ovi
  • 60
  • 8

1 Answers1

0

I think given your requirements you would be better to pass a model object from the Activity to the each of the fragments in turn. Each of the fragment's would store the data required in the model, and the once the last fragment is complete, it can be validated.

As a side note, I believe onSaveInstanceState is used for storing the current state of a Activity / Fragment so that it can be reinitalised without having to call possible long running background tasks rather than a way to share data.

Kingamajick
  • 2,281
  • 1
  • 16
  • 19
  • When is the right time to save to the model object, on fragment pause or on each change of the views? – Ovi Jan 15 '13 at 08:20