Will savedInstanceState
bundle in onCreate()
method be alive (not null) after Application is being killed? If it would, where this bundle is stored in the system.
The savedInstanceState is a reference to a Bundle object that is passed into the onCreate method of every Android Activity. Activities have the ability, under special circumstances, to restore themselves to a previous state using the data stored in this bundle.
1 Answer. Show activity on this post. You can replace above with the data you want to save and then re-populate your views like RecyclerView etc with the data you saved in the savedInstance as key-value pair. Just keep in mind that the Bundle is not meant to store Large amount of data.
After Orientation changed then onCreate(Bundle savedInstanceState) will call and recreate the activity and load all data from savedInstanceState. Basically Bundle class is used to stored the data of activity whenever above condition occur in app. onCreate() is not required for apps.
The logs always show the "bundle save" tag. But in onCreate method, SavedInstanceState is always null. you need to call super. onSaveInstanceState(savedInstanceState) before adding your values to the Bundle, or they will get wiped out on that call (Droid X Android 2.2).
If Android kills the process hosting your app, it still maintains the "saved instance state" of all active (non-finished) activities. This data is stored by the ActivityManager
. If the user returns to your application, Android will create a new process for the app, instantiate the Application
instance again and then create an instance of the top activity in the activity stack. It will then call onCreate()
on that activity instance passing it the "saved instance state" that was most recently saved for that activity.
If you reboot your phone, all this data is lost (Android does not save application state across reboots).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With