2

I use a cursor like following to retrieve contacts from the phone:

String[] selection = new String[]
            {
                    ContactsContract.Data.RAW_CONTACT_ID,
                    ContactsContract.Data.CONTACT_ID,
                    ContactsContract.Data.LOOKUP_KEY,
                    ContactsContract.Data.PHOTO_ID,
                    ContactsContract.Data.DISPLAY_NAME,
                    ContactsContract.Data.ACCOUNT_TYPE_AND_DATA_SET,
                    ContactsContract.CommonDataKinds.Phone.NUMBER,
                    ContactsContract.CommonDataKinds.Phone.TYPE,
                    ContactsContract.CommonDataKinds.Phone.LABEL,
                    ContactsContract.Contacts.Data.MIMETYPE,
                    ContactsContract.RawContacts.ACCOUNT_NAME
            };

    Cursor cursor = context.getContentResolver().query(
            ContactsContract.Data.CONTENT_URI,//ContactsContract.CommonDataKinds.Phone.CONTENT_URI
            selection,
            null,//Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
            null,
            ContactsContract.Data.CONTACT_ID + " ASC");

What does a null cursor mean?

  • something failed? If so, what? Rights? Or anything else?
  • user does not have any contacts?
prom85
  • 16,896
  • 17
  • 122
  • 242
  • I just need to know, what a null cursor means though, as I have to treat it somehow... I can treat it like an error or like zero contacts... and yeah, you are right, this error is REALLY RARE... but it happens – prom85 Jul 09 '15 at 08:31
  • possible duplicate of [What causes Android's ContentResolver.query() to return null?](http://stackoverflow.com/questions/13080540/what-causes-androids-contentresolver-query-to-return-null) – Sushant Jul 09 '15 at 08:41

0 Answers0