In apps that use phone authentication like whatsapp:
When any user opens to check his/her contacts, whatsapp will show only the contacts from your phone that are using whatsapp (like they filter your contacts).
My thoughts on implementing something similar:
I can save all users in a database (when they authenticate with my app), now when I load contacts in an activity I check to see if the contact exist in the database, and if the user exist then I add him/her to the list.
Problem:
If I used the above method:
Then lets say I have 10,000 users in the database, then it wont make sense to loop through 10,000 users every time I want to show contacts of a user inside my app.
Question:
How do you think apps like whatsapp implement such a thing?