Passionate programmer
Passionate programmer

Reputation: 5898

Why is android contact detail not shown?

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);
    }
}

Upvotes: 0

Views: 282

Answers (1)

Karan
Karan

Reputation: 12782

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 !

Upvotes: 2

Related Questions