I have an integer that I want to save. I have a class called saving and whenever a method called save()
is called, int save increments by one. But I am trying to use onSaveInstanceState
, but that won't work and it is never called. How do I save the integer save whenever the saving class is recalled? even on restoresavedinstance state doesn't work as suggested by jerry. Here is my code:
package browser.rarster.com.detailflow;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
/**
* Created by RichSharma on 4/28/15.
*/
public class saving extends ActionBarActivity {
int save = 0;
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("please", save);
Log.d("gave", "gave it" + save);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
Log.d("dude", "dude");
}
//just call give and give it bundle in giving web and then call savedInsatnce state there
public void give(){
save++;
}
public int givingWeb(){
return save;
}
}