数据库没有这个项,cursor的count为0
作者:互联网
比如说,联系人里面有个叫“jack"的人,只有名字,没有电话号码。
val queryFields2 = arrayOf(ContactsContract.CommonDataKinds.Phone.NUMBER) val phoneCursor = requireActivity().contentResolver .query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, queryFields2, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=" + id, null, null ) phoneCursor?.use { if (phoneCursor.count > 0) { phoneCursor.moveToFirst() Log.d("CrimeFragment", "测试") crime.suspectPhoneNumber = phoneCursor.getString(0) } else{ crime.suspectPhoneNumber = "" }
那么cursor的count会为0,因为找不到那个id的phone number。
标签:count,phoneCursor,ContactsContract,数据库,cursor,Phone,CommonDataKinds,id 来源: https://www.cnblogs.com/--here--gold--you--want/p/14847140.html