I have a variable that I have successfully saved and restored using onSaveInstanceState
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); // the UI component values are saved here.
outState.putDouble("VALUE", liter);
Toast.makeText(this, "Activity state saved", Toast.LENGTH_LONG).show();
}
But this only works if the activity is destroyed. I want to save the same variable by overriding the onPause() method and getting back when the activity is not not paused anymore any ideas on how to do this are greatly appreciated