Fetching a large number of contacts

后端 未结 1 585
别跟我提以往
别跟我提以往 2021-01-17 05:46

I\'m trying to fetch all the Phone numbers and Emails in Android.by using this code.

enter code here 

            String KEY_NAME = \"Name\";
            St         


        
相关标签:
1条回答
  • 2021-01-17 06:04

    I had very similar problem some time ago even with significantly lower number of contacts.

    I needed to populate all contacts in list view and allow the user to select from them. Initially I was loading all the contact information in the list view. However this required really a lot of queries, which is what actually is slow.

    So I changed my design: I selected only the Contact name and the Contact id and recorded it in an object. Afterwards when the user of my app selected any contact I loaded only his data. This turned to be drastically faster (as expected). And in my case it worked perfectly, because I was querying a lot of information which I actually never needed (that is phone numbers and emails of all not-selected contacts).

    Hopefully you will be able to redesign your app in similar way. However if you need to display the contents of the data variable in the listview right away, you really might turn to need lazy-loading list view with adapter (lets just hope it will perform smoothly even on fast scroll).

    0 讨论(0)
提交回复
热议问题