Example usage for android.content ContentProvider coerceToLocalContentProvider

List of usage examples for android.content ContentProvider coerceToLocalContentProvider

Introduction

In this page you can find the example usage for android.content ContentProvider coerceToLocalContentProvider.

Prototype

@UnsupportedAppUsage
public static ContentProvider coerceToLocalContentProvider(IContentProvider abstractInterface) 

Source Link

Document

Given an IContentProvider, try to coerce it back to the real ContentProvider object if it is running in the local process.

Usage

From source file:android.syncml.pim.vcard.VCardDataBuilder.java

private void tryGetOriginalProvider() {
    final ContentResolver resolver = mContentResolver;

    if ((mMyContactsGroupId = Contacts.People.tryGetMyContactsGroupId(resolver)) == 0) {
        Log.e(LOG_TAG, "Could not get group id of MyContact");
        return;// www. j  av a2s  .c  om
    }

    IContentProvider iProviderForName = resolver.acquireProvider(Contacts.CONTENT_URI);
    ContentProvider contentProvider = ContentProvider.coerceToLocalContentProvider(iProviderForName);
    if (contentProvider == null) {
        Log.e(LOG_TAG, "Fail to get ContentProvider object.");
        return;
    }

    if (!(contentProvider instanceof AbstractSyncableContentProvider)) {
        Log.e(LOG_TAG, "Acquired ContentProvider object is not AbstractSyncableContentProvider.");
        return;
    }

    mProvider = (AbstractSyncableContentProvider) contentProvider;
}