views:

116

answers:

1

I have the below code which is suppose to show a list of contact with check box on left side, I use Android API version 4 and running on a emulator with Android 2.1. The check box is shown but not the contact names right to check box is shown. What is that I am doing wrong.

public class CheckListActivity extends ListActivity {
    private SimpleCursorAdapter adapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Cursor c = getContentResolver().query(People.CONTENT_URI, null, null,
                null, null);
        startManagingCursor(c);
        String[] projection = new String[] { People.DISPLAY_NAME };
        int[] names = new int[] { R.id.text_view };
        adapter = new SimpleCursorAdapter(this, R.layout.main, c, projection, names);
        this.setListAdapter(adapter);
    }
}
+1  A: 

You are using the old contact provider, which might not be working with Android 2.1.

Please check the following link on how to use the Android 2.0 Contacts API.
http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/

HTH !

Karan