limiting number of rows in a ContentResolver.query() function

后端 未结 3 687
借酒劲吻你
借酒劲吻你 2020-12-30 19:22

Is there a way to limit the number of returned rows to a cursor? I have a phone with about 4000 contacts, I just need some of them.

this is the code i\'m using

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 19:39

    To limit the number of results in your cursor try:

    cursor = cr.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, ContactName + " LIMIT 100");
    while(cursor.moveToNext()) {
        // something clever
    }
    

提交回复
热议问题