0

我想获取所有 id 大于特定数字的联系人。

我的代码是:

    String xml = "[";
    max_contact_id="1000";

    final String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " ASC";

    Cursor cur = content.query(ContactsContract.Contacts.CONTENT_URI, null , ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" > ?",
            new String[]{max_contact_id}, sortOrder);

但它不会起作用。

4

1 回答 1

0

使用 LoaderManager.LoaderCallbacks 实现您的 Fragment 或 Activity

implements LoaderManager.LoaderCallbacks<Cursor> 



 @Override
    public Loader<Cursor> onCreateLoader(int id, @Nullable Bundle args) {
        return new CursorLoader(getActivity(),
                ContactsContract.CommonDataKinds.Phone.CONTENT_URI, ProfileQuery.PROJECTION,
                // Select only email addresses
                null, null, null);
    }

@Override
    public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
        cursor.moveToFirst();


        while (!cursor.isAfterLast()) {

            String phoneNumber = cursor.getString(ProfileQuery.NUMBER);
            String name = cursor.getString(ProfileQuery.NAME);
            cursor.moveToNext();
        }



    }
于 2018-07-09T09:39:36.030 回答