title: Why do contacts repeat in listview?
body: <p>I was following an example off of the android site.  I am new to android development.  The problem I am having is that my contacts repeat over and over, about 6 times.  Can anyone figure out why?  I feel it may have to do with my imports as they were not included with the example but I am not certain.  Also note that I did not create an xml file for the listview under res.
  Thanks,</p>
  
  <p><em>ListViewLoader.java</em></p>
  
  <pre><code>package com.example.contactlist;
  
  import android.app.ListActivity;
  import android.app.LoaderManager;
  import android.content.CursorLoader;
  import android.content.Loader;
  import android.database.Cursor;
  import android.widget.ListView;
  import android.widget.SimpleCursorAdapter;
  import android.os.Bundle;
  import android.provider.ContactsContract;
  import android.view.View;
  
  //from http://developer.android.com/guide/topics/ui/layout/listview.html
  
  public class ListViewLoader extends ListActivity implements
          LoaderManager.LoaderCallbacks&lt;Cursor&gt; {
  
      // This is the Adapter being used to display the list's data
      SimpleCursorAdapter mAdapter;
  
      // These are the Contacts rows that we will retrieve
      static final String[] PROJECTION = new String[] {
              ContactsContract.Data._ID, ContactsContract.Data.DISPLAY_NAME };
  
      // This is the select criteria
      static final String SELECTION = "((" + ContactsContract.Data.DISPLAY_NAME
              + " NOTNULL) AND (" + ContactsContract.Data.DISPLAY_NAME
              + " != '' ))";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
  
          // For the cursor adapter, specify which columns go into which views
          String[] fromColumns = { ContactsContract.Data.DISPLAY_NAME };
          int[] toViews = { android.R.id.text1 }; // The TextView in
                                                  // simple_list_item_1
  
          // Create an empty adapter we will use to display the loaded data.
          // We pass null for the cursor, then update it in onLoadFinished()
          mAdapter = new SimpleCursorAdapter(this,
                  android.R.layout.simple_list_item_1, null, fromColumns,
                  toViews, 0);
          setListAdapter(mAdapter);
  
          // Prepare the loader. Either re-connect with an existing one,
          // or start a new one.
          getLoaderManager().initLoader(0, null, this);
      }
  
      // Called when a new Loader needs to be created
      public Loader&lt;Cursor&gt; onCreateLoader(int id, Bundle args) {
          // Now create and return a CursorLoader that will take care of
          // creating a Cursor for the data being displayed.
          return new CursorLoader(this, ContactsContract.Data.CONTENT_URI,
                  PROJECTION, SELECTION, null, null);
      }
  
      // Called when a previously created loader has finished loading
      public void onLoadFinished(Loader&lt;Cursor&gt; loader, Cursor data) {
          // Swap the new cursor in. (The framework will take care of closing the
          // old cursor once we return.)
          mAdapter.swapCursor(data);
      }
  
      // Called when a previously created loader is reset, making the data
      // unavailable
      public void onLoaderReset(Loader&lt;Cursor&gt; loader) {
          // This is called when the last Cursor provided to onLoadFinished()
          // above is about to be closed. We need to make sure we are no
          // longer using it.
          mAdapter.swapCursor(null);
      }
  
      @Override
      public void onListItemClick(ListView l, View v, int position, long id) {
          // Do something when a list item is clicked
      }
  }
  </code></pre>