This :
@Override Public voidonsaveinstancestate (Bundle savedinstancestate) {Super. Onsaveinstancestate (savedinstancestate); //Save UI state changes to the savedinstancestate. //This bundle would be passed to onCreate if the process is//killed and restarted.Savedinstancestate.putboolean ("Myboolean",true); Savedinstancestate.putdouble ("MyDouble", 1.9); Savedinstancestate.putint ("MyInt", 1); Savedinstancestate.putstring ("MyString", "Welcome Back to Android"); //etc.}
The Bundle is essentially a storing a NVP ("Name-value Pair") map, and it'll get passed in to OnCreate and also onrestoreinstancestate where you ' d extract the Valu Es like this:@Override Public voidonrestoreinstancestate (Bundle savedinstancestate) {Super. Onrestoreinstancestate (savedinstancestate); //The Restore UI state is from the savedinstancestate. //This bundle had also been passed to OnCreate. BooleanMyboolean = Savedinstancestate.getboolean ("Myboolean"); DoubleMyDouble = savedinstancestate.getdouble ("MyDouble"); intMyInt = Savedinstancestate.getint ("MyInt"); String myString= Savedinstancestate.getstring ("MyString");} you do usually use ThisTechnique to store instance values forYour application (selections, unsaved text, etc.).
Original: Http://stackoverflow.com/questions/151777/saving-activity-state-in-android