1

Background: Seems like a solved problem: A chat application wishes to upload your local phonebook to their own servers to crosscheck the numbers so that in case one of your friends has registered with the service, they show up in a list that says "Hey chat with these people, they also have App X".

Naive solution: Android contacts Display Name and Phone Number(s) in single database query?

Approaches like the above query the Contacts ContentProvider for all the contact data on the phone. This data is then combined into contact entities, converted to JSON, and sent to a server where the phone and email credentials are checked against the database there.

Problem: This solution doesn't scale for a number of reasons. Consider something like a phone with 25,000 contacts (this happens with corporate users with something like LDAP)

  1. The query itself will be saved to a sqlite database in the app. This is needed so that domain related data model stuff can be saved with contacts that are registered and those that are not registered can also be displayed with invite buttons (think WhatsApp etc). Querying this table as a whole becomes an issue since a Cursor can only handle a result set of <= 1MB.
  2. Even if you can get all the Contacts into memory and convert them to JSON, you are now looking at like a 2MB String to upload to the server for sync. On poor networks, this could take a REALLY long time. Mostly this can be done in the background but it will become very obvious on the first time load and any subsequent changes to the local phone book (if you add a new contact who is a user of App X for instance).

Let's say that there is a way of uploading deltas after the initial launch as opposed to the entire contact book again each time the phonebook changes. Even then, you have the initial upload that either you block the user on to wait for or you end up with the user in an app with no contacts being shown.

Long story short, my questions are:

  1. How is this best done? Are large contact lists just not being considered for the majority of messaging apps?
  2. How can I make waiting for the initial upload a non-terrible UX?
  3. How can I test this case? Is there a tool I can use to programatically add thousands of contacts into the address book or do I have to roll my own?
Community
  • 1
  • 1
Andrew G
  • 1,547
  • 1
  • 13
  • 27
  • Oh, yeah ... just go ahead and *"upload **my** **entire(!)** **personal(!!)** phone book."* Just so that you can "suggest to me" ... while by-the-by you also can send/sell that list ... to ... ?!?!?! Yeah, don't reckon anyone on Planet Earth might *have a wee bit of a **problem*** with that, eh? – Mike Robinson Jul 26 '16 at 21:44
  • It's common practice. How do you think WhatsApp knows who else you know on whatsApp? – Andrew G Jul 26 '16 at 21:47
  • It is a common practice ***"now."*** But, only because "John Q. Public" has not yet become aware of what exactly you are doing. "To *me,* '*my* phone' is *mine,* as is all of the data that *I* might have chosen to store in it. "My list of contacts" might be, to *me,* **trade secret.** *(Yes, I am perfectly serious.)* At the very least, then, **"ask first!"** – Mike Robinson Jul 26 '16 at 21:51
  • You have to split this into multiple question. How to upload large file is one of them? – danny117 Jul 26 '16 at 21:54
  • The file upload itself is not the problem. Rather, the centrally important nature of the result of that upload as it applies to the app. Basically I'm looking to see if anyone can shed some light on scalable contact upload in general. – Andrew G Jul 26 '16 at 21:58

0 Answers0