Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice to show android contacts + phone numbers

What is the best approach from a performance perspective to show a ListView with contacts and their phone numbers?

  • Use CursorAdapter with the contacts cursor and make the phone numbers query when bindView is invoked for each row
  • Copy all the contacts and phone numbers to an in-memory array in a background thread and then show them with an ArrayAdapter.
  • Other solutions?
like image 393
ggarber Avatar asked Jul 20 '11 17:07

ggarber


People also ask

Why does my Android show phone numbers instead of contacts?

Turn Off/On "Hide Contacts Without Numbers" It is also possible that 'Hide Contacts Without Numbers' functions have been enabled after the Android update. It happens sometimes, and due to the activation of this option, Android not showing contact names. So, you have to just disable this option from the settings.


1 Answers

In my opinion a mix solution should be better. Why this? Because you don't know or it's suppose that in most of contexts you cannot know about how and how many contacts your application will need to list. An also how many contacts are stored in the phone. If we know both answers, surely we can take the most approach solution.

So I suggest you to first bring a fix number of contacts using an in-memory array in a background thread, for example the first 20. Also if you consider that your app will perform more than one request to this service.. it will be awesome to use a sort of caching. The worst approach should be to call again and again the contacts service. Then for a request for contact #21 you can bring next 20 and so on.

So you can use the advantages of both worlds, and minimize the disadvantages too. Always depends on the application and the context that we are talking about.

like image 142
matiasnj Avatar answered Oct 13 '22 10:10

matiasnj