Multiple Contact Picker List [getCheckedItemPositions()]
<p>Below is a my Contact_Picker class.  I am going to be using this class to create a list of contacts with checkboxes, giving the user the option to select multiple contacts from their phonebook.  I have a layout xml that I am using that has 2 buttons at the bottom:  Clear All and Done.  </p>

<p>When 'Done' is pressed, I need it to get all of the names that are checked, and save them in a list/preferences file.  Right now, I can find what POSITIONS are checked, but I don't know how to retrieve the corresponding information associated with them (the name/phone number of the selected contact).  I have searched for days on a method that will work, and have not come up with anything.  Any code/pseudo code/ideas are greatly appreciated.</p>

<p>Contact_Picker Class:</p>

<pre><code>public class Contact_Picker extends ListActivity {

    protected static final String TAG = null;
    public String[] Contacts = {};
    public int[] to = {};
    public ListView myListView;




    /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.contacts_list);

            final Button done_Button = (Button) findViewById(R.id.done_Button);
            final Button clear_Button =(Button) findViewById(R.id.clear_Button);

            Cursor mCursor = getContacts();
            startManagingCursor(mCursor);

            ListAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, mCursor,
                    Contacts = new String[] {ContactsContract.Contacts.DISPLAY_NAME },
                    to = new int[] { android.R.id.text1 });
            setListAdapter(adapter);
            myListView = getListView();
            myListView.setItemsCanFocus(false);
            myListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);



            clear_Button.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Toast.makeText(getApplicationContext(),"Selections Cleared", Toast.LENGTH_SHORT).show();
                    ClearSelections();
                }
            });

            /** When 'Done' Button Pushed: **/
            done_Button.setOnClickListener(new View.OnClickListener() {
                public void onClick (View v){


                    Log.i(TAG,":Done Button Selected:");
                    SparseBooleanArray checkedPositions = myListView.getCheckedItemPositions();
                    Log.i(TAG,"Number of Checked Positions: " + checkedPositions.size());
                    if (checkedPositions != null)
                    {
                        int count = myListView.getCount();
                        for ( int i=0;i&lt;count;i++)
                        {
                            Log.i(TAG,"Selected items: " + checkedPositions.get(i));
                        }
                    }

                }
            }); //&lt;-- End of Done_Button

        } //&lt;-- end of onCreate();


        private void ClearSelections() {            

            int count = this.myListView.getAdapter().getCount();

            for (int i = 0; i &lt; count; i++) {
                this.myListView.setItemChecked(i, false);
            }

        }

        private Cursor getContacts() {
            // Run query
            Uri uri = ContactsContract.Contacts.CONTENT_URI;
            String[] projection = new String[] { ContactsContract.Contacts._ID,
                    ContactsContract.Contacts.DISPLAY_NAME };
            String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '"
                    + ("1") + "'";
            String[] selectionArgs = null;
            String sortOrder = ContactsContract.Contacts.DISPLAY_NAME
                    + " COLLATE LOCALIZED ASC";

            return managedQuery(uri, projection, selection, selectionArgs,
                    sortOrder);
        } //&lt;-- end of getContacts();

}
</code></pre>

<p>Will Create Output Such As:</p>

<pre><code>Sele02-12 01:25:09.733: INFO/(219): :Done Button Selected:
02-12 01:25:09.743: INFO/(219): Number of Checked Positions: 2
02-12 01:25:09.743: INFO/(219): Selected items: true
02-12 01:25:09.743: INFO/(219): Selected items: false
02-12 01:25:09.743: INFO/(219): Selected items: true
02-12 01:25:09.752: INFO/(219): Selected items: false
</code></pre>
