permaculture playing cards*
The moose likes Android and the fly likes Regarding OnsaveInstanceState() and onRestoreInstanceState() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Regarding OnsaveInstanceState() and onRestoreInstanceState()" Watch "Regarding OnsaveInstanceState() and onRestoreInstanceState()" New topic
Author

Regarding OnsaveInstanceState() and onRestoreInstanceState()

kiruthigha rajan
Ranch Hand

Joined: Dec 29, 2011
Posts: 69
Hi im new to Android can anyone please tell me what does these two methods mean (OnsaveInstanceState() and onRestoreInstanceState() ).
and what is the purpose of using these methods...
Thanks in advance
Adnan Am
Greenhorn

Joined: Sep 14, 2012
Posts: 2
onSaveInstanceState() is a method used to store data before Pausing the activity & onRestoreInstanceState() is method used to retrieve that data back.

Consider this example here:

You app has 3 edit boxes where user was putting in some info , but he gets a call so if you didnt use the above methods what all he entered will be lost.

So always save the current data in onPause() method of Activity as a bundle & in onResume() method call the onRestoreInstanceState() method . !

Hope this helped
ankush deshpande
Greenhorn

Joined: Mar 17, 2013
Posts: 2
hey Rajan...
i am also a beginner in android programming. I refer to Slidenerd on Youtube for programming on Android. Hope this video helps you. cheeres!!!
https://www.youtube.com/watch?v=3FMn4FEv12M
 
Consider Paul's rocket mass heater.
 
subject: Regarding OnsaveInstanceState() and onRestoreInstanceState()