1## 3.18\. Contacts
2
3Android includes [`Contacts
4Provider`](https://developer.android.com/guide/topics/providers/contacts-provider)
5APIs to allow applications to manage contact information stored on the device.
6Contact data that is entered directly into the device is typically synchronized
7with a web service, but the data MAY also only reside locally on the device.
8Contacts that are only stored on the device are referred to as **local
9contacts.**
10
11[RawContacts](https://developer.android.com/reference/android/provider/ContactsContract.RawContacts)
12are "associated with" or "stored in" an
13[Account](https://developer.android.com/reference/android/accounts/Account)
14when the
15[`ACCOUNT_NAME`](https://developer.android.com/reference/android/provider/ContactsContract.SyncColumns.html#ACCOUNT_NAME),
16and
17[`ACCOUNT_TYPE`](https://developer.android.com/reference/android/provider/ContactsContract.SyncColumns.html#ACCOUNT_TYPE),
18columns for the raw contacts match the corresponding
19[Account.name](https://developer.android.com/reference/android/accounts/Account#name)
20and
21[Account.type](https://developer.android.com/reference/android/accounts/Account#type)
22fields of the account.
23
24**Default local account**: an account for raw contacts that are only stored on
25the device and not associated with an Account in the [AccountManager](
26https://developer.android.com/reference/android/accounts/AccountManager), which are
27created with *null* values for the
28[`ACCOUNT_NAME`](https://developer.android.com/reference/android/provider/ContactsContract.SyncColumns.html#ACCOUNT_NAME),
29and
30[`ACCOUNT_TYPE`](https://developer.android.com/reference/android/provider/ContactsContract.SyncColumns.html#ACCOUNT_TYPE),
31columns.
32
33**Custom local account**: an account for raw contacts that are only stored on the
34device and not associated with an Account in the AccountManager, which are
35created with *at least one non-null value* for the
36[`ACCOUNT_NAME`](https://developer.android.com/reference/android/provider/ContactsContract.SyncColumns.html#ACCOUNT_NAME),
37and
38[`ACCOUNT_TYPE`](https://developer.android.com/reference/android/provider/ContactsContract.SyncColumns.html#ACCOUNT_TYPE),
39columns.
40
41Device implementations:
42
43*    [C-SR] Are STRONGLY RECOMMENDED to not create **custom local accounts**.
44
45If device implementations use a **custom local account**:
46
47*    [C-1-1] The
48     [`ACCOUNT_NAME`](https://developer.android.com/reference/android/provider/ContactsContract.SyncColumns.html#ACCOUNT_NAME),
49     of the **custom local account** MUST be returned by
50     [`ContactsContract.RawContacts.getLocalAccountName`](https://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html#getLocalAccountName\(\))
51*    [C-1-2] The
52     [`ACCOUNT_TYPE`](https://developer.android.com/reference/android/provider/ContactsContract.SyncColumns.html#ACCOUNT_TYPE),
53     of the **custom local account** MUST be returned by
54     [`ContactsContract.RawContacts.getLocalAccountType`](https://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html#getLocalAccountType\(\))
55*    [C-1-3] Raw contacts that are inserted by third party applications with
56     the **default local account** (i.e. by setting null values for
57     `ACCOUNT_NAME` and `ACCOUNT_TYPE`) MUST be inserted to the **custom local
58     account**.
59*    [C-1-4] Raw contacts inserted into the **custom local account** MUST not be
60     removed when accounts are added or removed.
61*    [C-1-5] Delete operations performed against the **custom local account**
62     MUST result in raw contacts being purged immediately (as if the
63     [`CALLER_IS_SYNCADAPTER`](https://developer.android.com/reference/android/provider/ContactsContract.html#CALLER_IS_SYNCADAPTER)
64     param was set to true), even if the `CALLER\_IS\_SYNCADAPTER` param was set
65     to false or not specified.