Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding OnsaveInstanceState() and onRestoreInstanceState()

 
kiruthigha rajan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic