here is my code, when i click button "b" a listview populates with a checkbox for each item, now i want to get items with check box checked into another activity, how do i acheive this, i came half way i'm confused how to do the remaining part
here is my code XML file :
<Button
    android:id="@+id/b"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Pick contact" />
<ListView
    android:choiceMode="multipleChoice"
    android:id="@+id/lv"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />
This is java code:
import java.util.ArrayList;
import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
 import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
public class MainActivity extends Activity {
Button b;
int PICK_CONTACT;
ArrayList<String> al;
ArrayAdapter<String> aa;
ListView lv;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    b = (Button) findViewById(R.id.b);
    lv = (ListView) findViewById(R.id.lv);
    al = new ArrayList<String>();
    b.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            displaycontacts();
            System.out.println("size" + al.size());
            aa = new ArrayAdapter<String>(MainActivity.this,
                        android.R.layout.simple_list_item_multiple_choice, al);
            lv.setAdapter(aa);
        }
    });
    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position ,long arg3) 
        {
            //here i should get the item which is checked
        }
    });
}
public void displaycontacts() {
    try {
        ContentResolver cr = getContentResolver();
        Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
                null, null, null);
        if (cur.getCount() > 0) {
            while (cur.moveToNext()) {
                String name = cur
                        .getString(cur
                                .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                if (Integer
                        .parseInt(cur.getString(cur
                                .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
                    System.out.println("name : " + name);
                    al.add(name);
                }
            }
        }
    } catch (Exception e) {
        System.out.println("Error:::::::::::::::::::" + e);
    }
}
}
 
     
     
     
    