I have lists of times that I take with a timer, if I rotate the screen they are deleted. I tried following code, but it crashes. I think there is a problem in the saving/restoring format.
ArrayList<Long> timesList = new ArrayList<Long>(); // List of partial times in milliseconds
/** Save state while screen orientation changes */
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
// Save UI state changes to the savedInstanceState.
// This bundle will be passed to onCreate if the process is
// killed and restarted.
savedInstanceState.putSerializable("PartialTimes", timesList);
}
/** Restore state while screen orientation changes */
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
// Restore UI state from the savedInstanceState.
// This bundle has also been passed to onCreate.
timesList = (ArrayList<Long>) savedInstanceState.getSerializable("PartialTimes");
}