ContactsContract.Settings
public
static
final
class
ContactsContract.Settings
extends Object
implements
ContactsContract.SettingsColumns
| java.lang.Object | |
| ↳ | android.provider.ContactsContract.Settings |
Contacts-specific settings for various Account's.
A settings entry for an account is created automatically when a raw contact or group is inserted that references it. Settings entries cannot be deleted as long as raw contacts or groups continue to reference it; in order to delete a settings entry all raw contacts and groups referencing the account must be deleted first.
Columns
| Settings | |||
|---|---|---|---|
| String | ContactsContract.SettingsColumns.ACCOUNT_NAME |
read/write-once | The name of the account instance to which this row belongs. |
| String | ContactsContract.SettingsColumns.ACCOUNT_TYPE |
read/write-once | The type of account to which this row belongs, which when paired with
ContactsContract.SettingsColumns.ACCOUNT_NAME identifies a specific account. |
| int | ContactsContract.SettingsColumns.SHOULD_SYNC |
read/write | Depending on the mode defined by the sync-adapter, this flag controls the top-level sync behavior for this data source. |
| int | ContactsContract.SettingsColumns.UNGROUPED_VISIBLE |
read/write | Flag indicating if contacts without any
CommonDataKinds.GroupMembership entries should be visible in any
user interface. |
| int | ContactsContract.SettingsColumns.ANY_UNSYNCED |
read-only | Read-only flag indicating if this ContactsContract.SettingsColumns.SHOULD_SYNC or any
Groups.SHOULD_SYNC under this account have been marked as
unsynced. |
| int | ContactsContract.SettingsColumns.UNGROUPED_COUNT |
read-only | Read-only count of Contacts from a specific source that have
no CommonDataKinds.GroupMembership entries. |
| int | ContactsContract.SettingsColumns.UNGROUPED_WITH_PHONES |
read-only | Read-only count of Contacts from a specific source that have
no CommonDataKinds.GroupMembership entries, and also have phone
numbers. |
Summary
Nested classes | |
|---|---|
class |
ContactsContract.Settings.AccountAttributes
|
Constants | |
|---|---|
String |
ACTION_SET_DEFAULT_ACCOUNT
Action used to launch the UI to set the default account for new contacts. |
String |
CONTENT_ITEM_TYPE
The MIME-type of |
String |
CONTENT_TYPE
The MIME-type of |
Inherited constants |
|---|
Fields | |
|---|---|
public
static
final
Uri |
CONTENT_URI
The content:// style URI for this table |
Public methods | |
|---|---|
static
long
|
getAccountAttributes(ContentResolver resolver, Account account, String dataSet)
Returns the attributes of a given account as a 64-bit bitmask. |
static
Account
|
getDefaultAccount(ContentResolver resolver)
This method was deprecated
in API level 36.
This API is only supported up to Android version
* |
static
void
|
resetAccountAttributes(ContentResolver resolver, Account account, String dataSet)
Resets the attributes for a given account to their system-evaluated defaults. |
static
void
|
setAccountAttributes(ContentResolver resolver, Account account, String dataSet, long newAttributes)
Sets the attributes for a given account with a new set of flags. |
Inherited methods | |
|---|---|
Constants
ACTION_SET_DEFAULT_ACCOUNT
public static final String ACTION_SET_DEFAULT_ACCOUNT
Action used to launch the UI to set the default account for new contacts.
Constant Value: "android.provider.action.SET_DEFAULT_ACCOUNT"
CONTENT_ITEM_TYPE
public static final String CONTENT_ITEM_TYPE
The MIME-type of CONTENT_URI providing a single setting.
Constant Value: "vnd.android.cursor.item/setting"
CONTENT_TYPE
public static final String CONTENT_TYPE
The MIME-type of CONTENT_URI providing a directory of
settings.
Constant Value: "vnd.android.cursor.dir/setting"
Fields
CONTENT_URI
public static final Uri CONTENT_URI
The content:// style URI for this table
Public methods
getAccountAttributes
public static long getAccountAttributes (ContentResolver resolver, Account account, String dataSet)
Returns the attributes of a given account as a 64-bit bitmask.
A return value of 0L indicates the account exists but has no specific
attributes enabled or set.
Requires Manifest.permission.READ_CONTACTS
| Parameters | |
|---|---|
resolver |
ContentResolver: The ContentResolver to use for the query.
This value cannot be null. |
account |
Account: The account to query. If null, this queries the attributes of
the local, device-only account (where both account_name
and account_type are null). |
dataSet |
String: The data set specific to the account type, which may be null. |
| Returns | |
|---|---|
long |
A long representing the attributes bitmask.
Value is either 0 or a combination of the following:
|
| Throws | |
|---|---|
IllegalStateException |
if the specified account does not exist or its attributes could not be determined. |
getDefaultAccount
public static Account getDefaultAccount (ContentResolver resolver)
This method was deprecated
in API level 36.
This API is only supported up to Android version
* Build.VERSION_CODES.VANILLA_ICE_CREAM. On later versions,
ContactsContract.RawContacts.DefaultAccount.getDefaultAccountForNewContacts
should be used.
Get the account that is set as the default account for new contacts, which should be initially selected when creating a new contact on contact management apps. If the setting has not been set by any app, it will return null. Once the setting is set to non-null Account, it can still be set to null in the future.
| Parameters | |
|---|---|
resolver |
ContentResolver: the ContentResolver to query.
This value cannot be null. |
| Returns | |
|---|---|
Account |
the default account for new contacts, or null if it's not set or set to NULL account. |
resetAccountAttributes
public static void resetAccountAttributes (ContentResolver resolver, Account account, String dataSet)
Resets the attributes for a given account to their system-evaluated defaults.
This operation removes any explicit overrides set via
setAccountAttributes(ContentResolver, Account, String, long) and causes the system to immediately re-evaluate the
account's attributes based on its type and other characteristics
Security
This method requires that the calling application be the authenticator for the
account's type, as defined in AccountManager.
Requires Manifest.permission.WRITE_CONTACTS
| Parameters | |
|---|---|
resolver |
ContentResolver: The ContentResolver to use for the update.
This value cannot be null. |
account |
Account: |
dataSet |
String: The data set within the account, which may be null. |
| Throws | |
|---|---|
IllegalArgumentException |
if the target account is otherwise invalid. |
SecurityException |
if the calling package is not the authenticator for the account type. |
See also:
setAccountAttributes
public static void setAccountAttributes (ContentResolver resolver, Account account, String dataSet, long newAttributes)
Sets the attributes for a given account with a new set of flags.
Warning: This is a destructive operation. Any attributes previously
set on the account will be cleared and replaced by the provided newAttributes.
The provided bitmask must be valid and free of semantic conflicts (e.g.,
containing more than one DATA_ORIGIN type).
Security
This method requires that the calling application to be the authenticator
for the account's type.
Requires Manifest.permission.WRITE_CONTACTS
| Parameters | |
|---|---|
resolver |
ContentResolver: The ContentResolver to use for the update.
This value cannot be null. |
account |
Account: |
dataSet |
String: The data set within the account, which may be null. |
newAttributes |
long: The complete new bitmask of attributes to apply.
Value is either 0 or a combination of the following:
|
| Throws | |
|---|---|
IllegalArgumentException |
if newAttributes contains any undefined
bits, has semantic conflicts, or the account is
otherwise invalid. |
SecurityException |
if the calling package is not the authenticator for the account type. |
See also:
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-02-13 UTC.