# ContentProviderCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/content/ContentProviderCompat.java+class:androidx.core.content.ContentProviderCompat) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/core#1.3.0)

*** ** * ** ***


```
public final class ContentProviderCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/content/ContentProvider.html` in a backwards compatible fashion.

## Summary

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html` | `https://developer.android.com/reference/androidx/core/content/ContentProviderCompat#requireContext(android.content.ContentProvider)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/ContentProvider.html provider)` Returns NonNull context associated with given `https://developer.android.com/reference/android/content/ContentProvider.html`. |

## Public methods

### requireContext

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/core#1.3.0)

```
public static @NonNull Context requireContext(@NonNull ContentProvider provider)
```

Returns NonNull context associated with given `https://developer.android.com/reference/android/content/ContentProvider.html`. A provider must be declared in the manifest and created automatically by the system, and context is only available after `https://developer.android.com/reference/android/content/ContentProvider.html#onCreate()` is called.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/ContentProvider.html provider` | The `https://developer.android.com/reference/android/content/ContentProvider.html`. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html` | The `https://developer.android.com/reference/android/content/Context.html` object associated with the `https://developer.android.com/reference/android/content/ContentProvider.html`. |