Reputation: 11037
I am able to fetch contacts using this code https://stackoverflow.com/a/1780818/992774 , it works perfectly fine and returns all the emails and phone numbers.
But my problem is that when I have 10,000 of contacts it takes about 3-4 minutes and for that time it blocks my UI and looks like my app got halted. I have seen many apps like groupme which shows contacts without taking any time.
Can anyone suggest how to reduce the time while fetching contact thousand of contacts or how can I create custom cursor adapter?
Upvotes: 0
Views: 253
Reputation: 8641
use CursorLoader to get your cursor. It runs asynchronously, so you won't hang your UI thread while you're retrieving data.
It still may take some time. Is it worth stepping back for a second and asking if you need to look at 10,000 contacts? Seems to me that it's nearly impossible to search through them on the screen.
Upvotes: 1
Reputation: 4970
Can you do the loading in a separate thread, either using a Handler or an AsyncTask, for an example please refer to this tutorial http://www.vogella.de/articles/AndroidPerformance/article.html
This will leave your UI thread to be free to do UI stuff and you should be able to see your contacts get populated one by one on your screen.
Upvotes: 1