2

In my application I try to syncronize the contacts of the Phonebook with the users from Firebase. Therefore I query all contacts from Phonebook with ContactsContract.CommonDataKinds.Phone.CONTENT_URI and iterate through them to check each number:

databaseUsers.orderByChild("mobilnumber").equalTo(phoneNumber).addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {

I think this is the worst solution but I have no idea how to solve this problem. If users have many contacts it takes a long time to syncronize with Firebase with my code... Can you tell me how to solve this problem more efficient?

Moreover I have another problem with some numbers because in the Logcat I am missing some saved contacts from my phonebook. The code to get the numbers is the following:

String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));

Is something missing here to get ALL numbers? Thanks in advance!

Timitrov
  • 211
  • 1
  • 3
  • 14
  • I also face the same problem except I want to do the synchronization on iOS. I think the time is not the problem, you can split the contacts into many parts then do the synchronizing for each part within a separate thread, so it won't block your main thread and it reduces much more time. I suppose the problem here is if user has many contacts, each contact has many phone numbers or emails, the number of requests are sent to Firebase will be increased hugely. If your Firebase account is free or limited, it's a big problem, I'm afraid. – Scofield Tran Aug 28 '17 at 03:45
  • As this thread https://stackoverflow.com/questions/35538292/firebase-syncing-contacts-with-server discussion, we can download all users from firebase and take comparisons. But I think I also not efficient if the number of users up to thousands, ten thousands, hundred thousands or million users (if app reaches million users, it's worth to invest own server) – Scofield Tran Aug 28 '17 at 03:51

0 Answers0