Как получить контактный адрес электронной почты, телефон и имя, используя SimpleCursorAdapter - PullRequest
0 голосов
/ 04 октября 2018

Привет,

     String[] fromColumns = {
                ContactsContract.CommonDataKinds.Phone._ID,
                ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
                ContactsContract.CommonDataKinds.Phone.NUMBER
        };

        String[] SELECTED_COLUMNS = {
                ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
                ContactsContract.CommonDataKinds.Phone.NUMBER,
        };

        ContentResolver contentResolver = getContentResolver();
        Cursor cursor = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, fromColumns, null, null, null);


     SimpleCursorAdapter cursorAdapter = new SimpleCursorAdapter(
                this, // context
                R.layout.list_view, // layout that defines the views for this list item.
                cursor, // The database cursor
                SELECTED_COLUMNS, // "from" - column names of the data to bind to the UI
                toViews, // TextViews that should display column in the "from" param
                0 // Flags used to determine the behavior of the adapter
        );

У меня есть этот код для получения телефонных контактов с телефона и отображения в listView.Тем не менее, я хочу получать электронные письма от пользователей, но я не могу сделать это таким образом, потому что он находится под CommonDataKinds.Email, поэтому мне нужно создать два курсора для этого.Я не понимаю, какой курсор мне нужно добавить в cursorAdapter для получения электронной почты, телефона и имени?

...