public class

ContactsProvider2

extends SQLiteContentProvider
implements OnAccountsUpdateListener
java.lang.Object
   ↳ android.content.ContentProvider
     ↳ com.android.providers.contacts.SQLiteContentProvider
       ↳ com.android.providers.contacts.ContactsProvider2

Class Overview

Contacts content provider. The contract between this provider and applications is defined in ContactsContract.

Summary

Nested Classes
class ContactsProvider2.CommonDataRowHandler  
class ContactsProvider2.CustomDataRowHandler  
class ContactsProvider2.EmailDataRowHandler  
class ContactsProvider2.GroupIdCacheEntry An entry in group id cache. 
class ContactsProvider2.GroupMembershipRowHandler  
class ContactsProvider2.NicknameDataRowHandler  
class ContactsProvider2.OrganizationDataRowHandler  
class ContactsProvider2.PhoneDataRowHandler  
class ContactsProvider2.PhotoDataRowHandler  
class ContactsProvider2.StructuredNameRowHandler  
class ContactsProvider2.StructuredPostalRowHandler  
Constants
String DEFAULT_ACCOUNT_TYPE
String FEATURE_LEGACY_HOSTED_OR_GOOGLE
[Expand]
Inherited Constants
From interface android.content.ComponentCallbacks2
[Expand]
Inherited Fields
From class com.android.providers.contacts.SQLiteContentProvider
Public Constructors
ContactsProvider2()
Public Methods
void appendContactFilterAsNestedQuery(StringBuilder sb, String filterParam)
void appendRawContactsByFilterAsNestedQuery(StringBuilder sb, String filterParam)
ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
int delete(Uri uri, String selection, String[] selectionArgs)
int deleteData(long dataId, String[] allowedMimeTypes)
Delete a data row provided that it is one of the allowed mime types.
int deleteGroup(Uri uri, long groupId, boolean callerIsSyncAdapter)
void deleteNameLookup(long dataId)
Deletes all NAME_LOOKUP table rows associated with the specified data element.
int deleteRawContact(long rawContactId, long contactId, boolean callerIsSyncAdapter)
String getContactsRestrictionExceptionAsNestedQuery(String contactIdColumn)
String getRawContactsByFilterAsNestedQuery(String filterParam)
String getType(Uri uri)
Uri insert(Uri uri, ContentValues values)
void insertNameLookup(long rawContactId, long dataId, int lookupType, String name)
Inserts a record in the NAME_LOOKUP table.
String insertNameLookupForEmail(long rawContactId, long dataId, String email)
void insertNameLookupForNickname(long rawContactId, long dataId, String nickname)
Normalizes the nickname and inserts it in the name lookup table.
void insertNameLookupForOrganization(long rawContactId, long dataId, String company, String title)
void insertNameLookupForPhoneticName(long rawContactId, long dataId, String familyName, String middleName, String givenName)
void insertNameLookupForPhoneticName(long rawContactId, long dataId, ContentValues values)
void insertNameLookupForStructuredName(long rawContactId, long dataId, String name, int fullNameStyle)
long insertStatusUpdate(ContentValues values)
Inserts a status update.
long lookupContactIdByLookupKey(SQLiteDatabase db, String lookupKey)
Returns the contact Id for the contact identified by the lookupKey.
void onAccountsUpdated(Account[] accounts)
void onConfigurationChanged(Configuration newConfig)
boolean onCreate()
AssetFileDescriptor openAssetFile(Uri uri, String mode)
Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
int update(Uri uri, ContentValues values, String selection, String[] selectionArgs)
void updateLookupKeyForRawContact(SQLiteDatabase db, long rawContactId)
void updateRawContactDisplayName(SQLiteDatabase db, long rawContactId)
Updates a raw contact display name based on data rows, e.g.
Protected Methods
void beforeTransactionCommit()
int deleteInTransaction(Uri uri, String selection, String[] selectionArgs)
The equivalent of the delete(Uri, String, String[]) method, but invoked within a transaction.
ContactsDatabaseHelper getDatabaseHelper(Context context)
Account getDefaultAccount()
LegacyContactImporter getLegacyContactImporter()
Locale getLocale()
Uri insertInTransaction(Uri uri, ContentValues values)
The equivalent of the insert(Uri, ContentValues) method, but invoked within a transaction.
boolean isAggregationUpgradeNeeded()
boolean isLegacyContactImportNeeded()
boolean isWritableAccount(String accountType)
Returns true if the specified account type is writable.
void notifyChange(boolean syncToNetwork)
void notifyChange()
void onBeginTransaction()
void setProviderStatus(int status)
int updateInTransaction(Uri uri, ContentValues values, String selection, String[] selectionArgs)
The equivalent of the update(Uri, ContentValues, String, String[]) method, but invoked within a transaction.
void upgradeAggregationAlgorithm()
void verifyAccounts()
void verifyLocale()
Verifies that the contacts database is properly configured for the current locale.
[Expand]
Inherited Methods
From class com.android.providers.contacts.SQLiteContentProvider
From class android.content.ContentProvider
From class java.lang.Object
From interface android.accounts.OnAccountsUpdateListener
From interface android.content.ComponentCallbacks
From interface android.content.ComponentCallbacks2
From interface android.database.sqlite.SQLiteTransactionListener

Constants

public static final String DEFAULT_ACCOUNT_TYPE

Constant Value: "com.google"

public static final String FEATURE_LEGACY_HOSTED_OR_GOOGLE

Constant Value: "legacy_hosted_or_google"

Public Constructors

public ContactsProvider2 ()

Public Methods

public void appendContactFilterAsNestedQuery (StringBuilder sb, String filterParam)

public void appendRawContactsByFilterAsNestedQuery (StringBuilder sb, String filterParam)

public int delete (Uri uri, String selection, String[] selectionArgs)

public int deleteData (long dataId, String[] allowedMimeTypes)

Delete a data row provided that it is one of the allowed mime types.

public int deleteGroup (Uri uri, long groupId, boolean callerIsSyncAdapter)

public void deleteNameLookup (long dataId)

Deletes all NAME_LOOKUP table rows associated with the specified data element.

public int deleteRawContact (long rawContactId, long contactId, boolean callerIsSyncAdapter)

public String getContactsRestrictionExceptionAsNestedQuery (String contactIdColumn)

public String getRawContactsByFilterAsNestedQuery (String filterParam)

public String getType (Uri uri)

public Uri insert (Uri uri, ContentValues values)

public void insertNameLookup (long rawContactId, long dataId, int lookupType, String name)

Inserts a record in the NAME_LOOKUP table.

public String insertNameLookupForEmail (long rawContactId, long dataId, String email)

public void insertNameLookupForNickname (long rawContactId, long dataId, String nickname)

Normalizes the nickname and inserts it in the name lookup table.

public void insertNameLookupForOrganization (long rawContactId, long dataId, String company, String title)

public void insertNameLookupForPhoneticName (long rawContactId, long dataId, String familyName, String middleName, String givenName)

public void insertNameLookupForPhoneticName (long rawContactId, long dataId, ContentValues values)

public void insertNameLookupForStructuredName (long rawContactId, long dataId, String name, int fullNameStyle)

public long insertStatusUpdate (ContentValues values)

Inserts a status update.

public long lookupContactIdByLookupKey (SQLiteDatabase db, String lookupKey)

Returns the contact Id for the contact identified by the lookupKey. Robust against changes in the lookup key: if the key has changed, will look up the contact by the raw contact IDs or name encoded in the lookup key.

public void onAccountsUpdated (Account[] accounts)

public void onConfigurationChanged (Configuration newConfig)

public boolean onCreate ()

public AssetFileDescriptor openAssetFile (Uri uri, String mode)

public Cursor query (Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)

public int update (Uri uri, ContentValues values, String selection, String[] selectionArgs)

public void updateLookupKeyForRawContact (SQLiteDatabase db, long rawContactId)

public void updateRawContactDisplayName (SQLiteDatabase db, long rawContactId)

Updates a raw contact display name based on data rows, e.g. structured name, organization, email etc.

Protected Methods

protected void beforeTransactionCommit ()

protected int deleteInTransaction (Uri uri, String selection, String[] selectionArgs)

The equivalent of the delete(Uri, String, String[]) method, but invoked within a transaction.

protected ContactsDatabaseHelper getDatabaseHelper (Context context)

protected Account getDefaultAccount ()

protected LegacyContactImporter getLegacyContactImporter ()

protected Locale getLocale ()

protected Uri insertInTransaction (Uri uri, ContentValues values)

The equivalent of the insert(Uri, ContentValues) method, but invoked within a transaction.

protected boolean isAggregationUpgradeNeeded ()

protected boolean isLegacyContactImportNeeded ()

protected boolean isWritableAccount (String accountType)

Returns true if the specified account type is writable.

protected void notifyChange (boolean syncToNetwork)

protected void notifyChange ()

protected void onBeginTransaction ()

protected void setProviderStatus (int status)

protected int updateInTransaction (Uri uri, ContentValues values, String selection, String[] selectionArgs)

The equivalent of the update(Uri, ContentValues, String, String[]) method, but invoked within a transaction.

protected void upgradeAggregationAlgorithm ()

protected void verifyAccounts ()

protected void verifyLocale ()

Verifies that the contacts database is properly configured for the current locale. If not, changes the database locale to the current locale using an asynchronous task. This needs to be done asynchronously because the process involves rebuilding large data structures (name lookup, sort keys), which can take minutes on a large set of contacts.