I have a multiple activity app – MainActivity, CpuActivity, etc. My CpuActivity has fragments that have savedInstanceState. Whenever I press back or navigate up to the MainActivity the CpuActivity is killed and the savedInstanceState is lost. Is it possible to keep the saved data/activity in the background or do I need to use some kind of temporary storage (e.g. SharedPreferences)?
The data should only be stored until the whole app is killed, so is there any system better than SharedPreferences?
A simple solution is to store the data in your application instance. To do that you have to specify an Application implementation in the manifest (the android:name attribute in the application tag). You can get the application using the getApplication() method.