title: How can I save the ListView to restore?
body: <p>How can I save the ListView and restore it by resume? Because when i close the app all contents are delete.</p>
  
  <p>Thanks for answers</p>
  
  <p>public class ToDoList extends Activity {</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      ListView myListView = (ListView)findViewById(R.id.todolist);
      final EditText myEditText = (EditText)findViewById(R.id.addtodo);
      final ArrayList todoItems = new ArrayList();
      final ArrayAdapter aa;
      aa = new ArrayAdapter(this,
      android.R.layout.simple_list_item_1,
      todoItems);
      myListView.setAdapter(aa);
  
      String edittext="";
      SharedPreferences settings = getSharedPreferences("PreferencesName", 0);
      edittext = settings.getString("Content", edittext);
      todoItems.add(0, edittext);
  
      myEditText.setOnKeyListener(new OnKeyListener() {
      public boolean onKey(View v, int keyCode, KeyEvent event) {
      if (event.getAction() == KeyEvent.ACTION_DOWN)
      if (keyCode == KeyEvent.KEYCODE_ENTER){
      todoItems.add(0, myEditText.getText().toString());
      aa.notifyDataSetChanged();
  
      String edittext= myEditText.getText().toString();
      SharedPreferences settings = getSharedPreferences("PreferencesName", 0);
      SharedPreferences.Editor editor = settings.edit();
      editor.putString("Content",  edittext);
  
      myEditText.setText("");
      return true;
      }
      return false;
      }
      });
      }}
  </code></pre>