0

It is said that we can preserve data on Activity's death by overriding onSaveInstanceState(). All data we put there will be saved somewhere in the OS.

My question is - for how long will OS hold that data? Is it predictable at all?

2 Answers2

1

You really shouldn't be thinking about these kinds of things as these are the states of event driven data. The Event is you are transitioning activities and leaving the activity, which will execute the onPause() in which cause you store your data in the onSaveInstanceState() and during the onResume() restore your data from the bundle from onRestoreInstanceState().

If you are TRULY worried about this, then consider storing your data permanently in your app space like SharedPerferences or some local file.

Also a little FYI, if your are thinking about this, have you considered that perhaps what you're doing is bad design?

JoxTraex
  • 13,423
  • 6
  • 32
  • 45
0

As usual, it has already been a better discussion: Saving Activity state in Android

In any case, the topic seem to be a controversy since the life span of transient state data is not very well defined, nor can it be predicted.

Community
  • 1
  • 1