安卓android的联系人的contacts, raw contacts, and data的区别
https://stackoverflow.com/questions/5151885/android-new-data-record-is-added-to-the-wrong-contact/5158059#5158059
https://developer.android.com/guide/topics/providers/contacts-provider.html
https://stackoverflow.com/questions/35448250/how-to-get-whatsapp-contacts-from-android/35453979#35453979
https://developer.android.com/reference/android/provider/ContactsContract.RawContactsEntity.html
https://developer.android.com/reference/android/provider/ContactsContract.Data.html
Couple of Key pointers:
- Contacts._ID = Data.CONTACT_ID
- RawContacts._ID = Data.RAW_CONTACT_ID
- RawContacts.CONTACT_ID = Contacts._ID
- RawContactsEntity._ID = RawContacts._ID
Sounds confusing?? Let me try...
- The Contacts database is divided into 3 tables contacts, raw contacts, and data.
- Each table contains column (_ID) which is an auto incremented primary key.
- data table contains all the contact info like phone number, mail id, address etc.
- The raw contacts points to the actual contact created. Hence we use the raw contacts while adding a contact.
- The user cannot add any data in the contacts table. The data in this table is populated internally due to aggregation of contacts.
- The reason your logic worked for some of the contacts is: _ID for contacts, raw contactsremains same until there is any contact aggregation taking place. Lets say you add two contacts with same name abc. Here the _ID for raw contacts increments twice while _ID forcontacts increments only once as these two contacts gets merged due to the aggregation of contacts
Refer this for more details.
The best approach to fetch the info in your case is by using ContactsContract.RawContactsEntity ( an outer join of the raw_contacts table with the data table)
Reference:http://developer.android.com/reference/android/provider/ContactsContract.RawContactsEntity.html
here is the show Android Contact Data Store Diagram

安卓android的联系人的contacts, raw contacts, and data的区别的更多相关文章
- Android根据联系人姓名首字符顺序读取通讯录
Android根据联系人姓名首字符顺序读取通讯录 版权声明:本文为Zhang Phil原创文章,欢迎转载!转载请注明出处:http://blog.csdn.net/zhangphil 本文给出了A ...
- android管理联系人操作
ContentProvider扩展之管理系统联系人 我们都知道ContentProvider是用来共享数据的,然而android本身就提供了大量的ContentProvider,例如联系人信息,系统的 ...
- Android系统联系人全特效实现(下),字母表快速滚动
在上一篇文章中,我和大家一起实现了类似于Android系统联系人的分组导航和挤压动画功能,不过既然文章名叫做<Android系统联系人全特效实现>,那么没有快速滚动功能显然是称不上&quo ...
- Android系统联系人全特效实现(上),分组导航和挤压动画
记得在我刚接触Android的时候对系统联系人中的特效很感兴趣,它会根据手机中联系人姓氏的首字母进行分组,并在界面的最顶端始终显示一个当前的分组.如下图所示: 最让我感兴趣的是,当后一个分组和前一个分 ...
- 安卓Android面试题大全
56个问题都是经常用到的,可以深入研究下,也是必须掌握的开发必备知识. 安卓Android面试题汇总 搜集了一些Android面试题目,供将要面试或者正在面试的朋友参考. 1, 谈谈你对Activit ...
- Win7的64位系统如何搭建安卓Android开发环境
在搭建安卓Android开发环境,那么现在比较主流的Win7的64位操作系统如何搭建呢?其实很简单,不需要设置任何环境变量,只需要下载两个程序包(ADT和JDK),下载的时候注意选择相应的64位程序包 ...
- Python 开发安卓Android及IOS应用库Kivy安装尝试
Python 开发安卓Android及IOS应用库Kivy安装尝试: 先来看看这货可以用来制作什么应用: Create a package for Windows Create a package f ...
- android开发如何获取res/raw和assets文件夹的路径
---恢复内容开始--- android开发如何获取res/raw和assets文件夹的路径,主要分为两种情况: 1.如果你只是拷贝动作,那么你只需要得到res/raw和assets文件输入流就可以, ...
- VS2015配置安卓Android和iOS开发环境
http://www.cjjjs.cn/paper/gzsh/627201502818357.aspx [摘要] 本文按照步骤一步步的介绍要下载安装的东西,都提供了下载地址.最后将所有需要的程序都打包 ...
随机推荐
- 关于Unity的C#基础学习(二)
一.Debug的使用 int a=3; Debug.Log("a="+a); 二.整数的定义 int m; Debug.Log(m); //C#比C更严谨,没有初始化的变量打印出 ...
- mac环境搭建selenium
前言 搭建python+selenium,mac自带python2.7,需要公司使用的python是3.x,可以自己百度安装python环境. 1. selenium安装 1. selenium的安装 ...
- elasticsearch中mapping的_source和store的笔记
0.故事引入 无意中看到了ES的mapping中有store字段,作为一个ES菜鸡,有必要对这个字段进行下笔记. 1._source _source字段我在们进行检索时相当重要, ES默认检索只会返回 ...
- 根据List<SqlParameter>返回sql条件(where后)
/// <summary> /// 根据参数列表返回sql条件(where后) /// </summary> /// <param name="list&quo ...
- mysql更改utf8编码方式
方法1: 一.查看数据库编码格式 1 mysql> show variables like 'character_set_database'; 二.查看数据表的编码格式 1 mysql> ...
- C# 直接调用非托管代码的方法
C# 代码有以下两种可以直接调用非托管代码的方法: 直接调用从 DLL 导出的函数. 调用 COM 对象上的接口方法. 对于这两种技术,都必须向 C# 编译器提供非托管函数的声明,并且还可能需要向 C ...
- u盘作为git仓库,完成不同地方的代码同步
参考网上一篇 "把Git Repository建到U盘上去" 1.我经常有这样的需求,工作.家里需要对同一份代码或文档编辑,并希望在不同地方能同步: 如果是私密性不那么强,可以直接 ...
- 去除 \ufeff
语言:python 编程工具:pycharm 硬件环境:win10 64位 读取文件过程中发现一个问题:已有记事本文件(非空),转码 UTF-8,复制到pycharm中,在开始位置打印结果会出现 \ ...
- mysql关联取附表最后一条记录,附加lareval orm实现
MySQL 多表关联一对多查询取最新的一条数据:https://blog.csdn.net/u013902368/article/details/86615382 Laravel query buil ...
- Fragment之间传数据
1.用bundle存Bundle bundle = new Bundle();bundle.putString("cid1", classList.get(i).getId()); ...