I have an Activity A
that opens Activity B
. During B's lifecycle, it creates lots of data that is important for later use. When I leave Activity B
, it gets destroyed. I want that when a user opens B next time, that important data would be restored.
So the question is, how to store that important data?
I had several assumptions:
SharedPreferences (
context.getPrecerence(MODE_PRIVATE)
). This is not a good options, because it allows saving only primitive types. I need to save java.io.Serializable object (or at leastParcelable
).Static variable - not an option. I want my data to remain even if JVM destroys my process when the user navigates to some other app.
Context.openFileOutput()
. Is this OK to make I/O every time I enter activity/quit it?
Something else?