How to get the group in which contact belongs to? - android

Android contacts Display Name and Phone Number(s) in single database query?
The above link gives the details to get the phone number and name in the contacts database.
I also want the group to which the contact belongs to ? How to get this from contacts uri?

you need a rooted phone
install the Root Explorer app
go to /data/data/android.providers.contacts/databases, and you can see all the data tables there.
then it is all about sql

Related

How to get contacts from contact list in Android? using Contact Provider

I had to fetch contact list from android using contact provider, but it was showing me duplicate entries. So, How can I filter those duplicate entries.
For example, ABCD - 123467890, 1234567890, 1234567890
how to filter duplicate phone number using contact Provider?
And Can I fetch only phone memory contact list?
It is obvious to get duplicate contacts when you fetch them. Since, same contact (same number, different name or different number, same name) might be stored in either in google contacts, phone contacts or in sim contacts.
In order to eliminate duplicates in your application, use local database (SQLite provided by android) and make phone number as unique, no duplicates will be stored.
For more information refer this post How to get all android contacts but without those which are on SIM
Following Dalma Racz comment, will also lead you to the solution.

Which contacts have my application installed?

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

chat names in msgstore.db whatsapp

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.

Getting account type of contacts table for accessing phone contact

I have a requirement, in which I have to add contacts into phone contact. I have Huawei android phone for which I got account type of phone contact as "com.android.huawei.phone" and account name as "PHONE". Using this data, I successfully inserted the contact and same is also appearing in phone contact. But, this will make my application device specific. Is there any way so that application works on every device? Is there any standard as which account type and name of contact table should be declared?
My problem has been solved. If we assign null to account name and account type, then we can easily add contacts in phone contacts.

Android Contact Search only phone book

I need to find contact which saved in my Android phone, But save numbers are repeated in SIM and Google contact, Then That are returning before return Phone contact.
Is there any way to query phone contacts only?
Thank You.
use ContactsContract.Contacts class. it will give you all data for contacts only.

Categories

Resources