In the onCreate()
of my MainActivity
, my app does an intensive operation to generate some data set (runs in a separate thread, but takes some 2 - 3 seconds to complete normally). Now my problem is that, when orientation changes, the app again does this complex computation again.
Since I haven't done anything like this before, I was wondering if there is a way around this. My first thought was to store the computed data in a static
variable, so that the data is persisted between different instances of MainActivity
. I am guessing this is not the best approach.
My data set consists of a Map
and an ArrayList
and not a simple data type, if it helps.
I have looked at the onSaveInstanceState()
, but it only provides to store values like int, String, etc.