title: Android save and restore ArrayList <Long> while screen changes
body: <p>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.</p>
  
  <pre><code>ArrayList&lt;Long&gt; timesList = new ArrayList&lt;Long&gt;(); // 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&lt;Long&gt;) savedInstanceState.getSerializable("PartialTimes");
  
  }
  </code></pre>