I'm building a small app for messaging (in some way a bit similar to 'WhatsApp' or 'Viber'). WhatsApp and Viber show you contacts that are from your contact list and have an account with them. so my question is how to sync?
For now, I have database which stores all users using the application and their phone number.
Do I need to run a query for each contact in my phone in order to find it in the database?
It looks a lot of queries for every sync request.
What is the efficient way in order to do this?
If you have both sets of data as database tables, then can't you just join on some attribute like 'Full Name' and the resulting table will be all people in your contacts list with the app installed?
You can display contacts in your app that are just pulled from the contact list on the phone. Using LoadManager you can get a contact list that is synced with the phone list.
Check out these links for more info
http://developer.android.com/training/contacts-provider/retrieve-names.html
https://developer.android.com/training/load-data-background/setup-loader.html
Related
As an android user, I would like to develop an app that installs a local contacts repo that is in parallel with the Google and Samsung contact providers/repos.
The reason is adding temporary contacts with a TTL. When looking for an apartment, I don't want all these random contacts. When selling something, I have just multitudes of contacts with no names just so I don't save these temps. When calling up moving companies, or any temporary agency ... I do not want these contacts forever on my phone.
How do I create a custom contacts repo such as in manage accounts?
I looked all over for something like this, and I found ContactProvider which felt like the right one, but after reading the docs, it doesn't quite fit. Tried AccountProvider but that is mostly about authorization from what I understand.
How can I add a contact provider such as Google Contacts or Samsung Contacts?
I am creating a custom app for planning events. It has a SMS based authentication. Now I want to create a list of people who are already using the app (like the list of contacts in WhatsApp). Is there any way to do this in Android?
If I get you right, you can do this in 3 steps:
When a user registers on your app, save the user in say "ActiveNumbers" database on your server.
Ask contacts permission from users.
Do a join of the contacts and ActiveNumbers table, list the valid contacts in the people section of your app.
Does it solve your problem?
In my android application I would like to display the mobile user's contacts (names, profile picture ) displaying first the contacts that have already installed and registrered that application (the matching is made by contact's email).
Trying to loop over each contact and match if their email is already registered (in an external SQLITE table) don't seems to be an efficient way.
I would like to directly add (somewhere in the address book ?) the extra data "isRegistered = true/false) and order my addreess book query by this value to scroll the address book.
Is it possible? How to implement this in detail ?
OPTION 1
I think the most efficient way would be what you thought about initially, with a slight improvement:
store the list of registered emails (for the user's contacts) in a local SQLite DB.
read the entire list of emails on application launch, and store them in a HashSet
When sorting the contacts, create a custom Comparator to first check if the contact is an app user or not, and only then fallback to name compare.
OPTION 2
If you still want to check the option of storing the custom value in the Contacts DB, and integrate it into your query, you need to create a SyncAdapter.
This is basically a service that is able to sync contacts to/from a server into your own RawContact, which is then aggregated into one-or-more existing RawContacts, like Google does for Google Contacts.
You can set it to be notified when a new contact is added, and have your SyncAdapter add the needed info to the contact so it'll show links to your app.
If you go to your phone settings > accounts, you can see Whatsapp and Google's SyncAdapters there, where you can turn them off/on.
To create a sync adapter, you can follow the official docs, or this great tutorial.
I'm currently working on a little program which should give me some statistics about my whatsapp usage.
So my question is:
Is there any way to get the names of whatsapp contacts whose chats are in the msgstore.db which i got from /data/data/com.whatsapp/databases?
So e.g if i have any Chat with anon, it only shows up in the table as "#s.whatsapp.net"
Is there any other database by WhatsApp which holds all the different chatnames or am i forced to export the contacts in my phone book and then associate the entry in the database with the phone numbers of the specific contact?
I hope i explained it understandable enough.
Thanks in advance
You can look into the display names from wa.db , table name is wa_contacts.Watsapp has two main databases. msgstore.db and wa.db. As you already know the messages reside in messages table and the corresponding contacts are in phonenumber#watsapp.net format and groups are adminphonenumber#watsapp.g.us. These ids are mapped with the names in wa_contacts table.
No its not possible android does not allow to read any other application database. As every application Runs in its own sand box.
This is my first application in Android. I am trying to maintain a list of contacts (a subset of the phone contacts) in my own application. I was to an extent read the contacts from Android and try to manipulate with it. But the challenge I face is,
Storing the contacts (persisting) in the application preferably through Preferences. (ListPreference not usable for this).
I only need name, phone number and email from every contact and display it in a list view.
The equivalent iPhone version looks like this. But how to close achieve this in Android
Any tips on achieving the above is much appreciated.
If it is a subset of the phone contacts why don't you store in a SQLite table just the lookup-URI of the contacts you want to have in your subset? You can store both the contact lookup-URI and ID if you are worried about the performances of lookup-uri.