title: Android - What is the right way to save/restore a ListView adapter?
body: <p>I want to save/restore, in changing orientation, a <code>List&lt;Contact&gt;</code> instance for a <code>ListView</code>; <code>Contact</code> is the item to show in a custom array adapter. </p>
  
  <p>I'm saving the List underlying the adapter in <code>onSaveInstanceState(Bundle savingInstanceState)</code> activity method:</p>
  
  <pre><code>savingInstanceState.putSerializable(""+R.id.contactList, (Serializable)adapter.contacts());
  </code></pre>
  
  <p>Then in <code>onRestoreInstanceState(Bundle savedInstanceState)</code> I restore and set the adapter:</p>
  
  <pre><code>    List&lt;Contact&gt; contacts =  
          (List&lt;Contact&gt;)savedInstanceState.getSerializable(""+R.id.contactList);
      ContactListAdapter adapter = 
          new ContactListAdapter((Context)this, android.R.layout.simple_list_item_1, contacts);
      contactList.setAdapter(adapter);
      adapter.notifyDataSetChanged();
  </code></pre>
  
  <p>Is it the right way to do it?</p>
  
  <p>Do you have a better/smarter solution?</p>
  
  <p>Thank you</p>