title: Android: Saving items selected in a multiple choice list view
body: <p>I am trying to understand where to save the selected list view items from this code.  With a dialog box you have an "ok/cancel" button option, is this possible with lists? Ideally I will be storing data from four different lists into a database on submit.  In the below picture I would like to save the first three items into a database, or even an array just to start.</p>
  
  <pre><code>package com.example.lifebyfourlists;
  
  import android.app.ListActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.Toast;
  
  public class MainActivity extends ListActivity{
      String [] seven = { 
              "Dark Leafy Greens" , 
              "Nuts", 
              "Carrots",
              "Green Tea", 
              "Whole Grains", 
              "Fruits"};
  
      public void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          ListView lstView = getListView();
          lstView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
          lstView.setTextFilterEnabled(true);
          setListAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_checked, seven));
      }
  
      public void onListItemClick(ListView parent, View v, int position, long id){
          Toast.makeText(this, "You have selected " + seven[position], Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/q3ldB.png" alt="Screen shot"></p>