# ComposeUiSharedResources

> Resource caches shared by Compose hierarchies that use the same `Context`, such as the caches used by `painterResource` to resolve drawable resources.

## API Reference

> Source set: Android

```kotlin
public class ComposeUiSharedResources(initialConfiguration: Configuration)
```

Resource caches shared by Compose hierarchies that use the same `Context`, such as the caches
used by `painterResource` to resolve drawable resources.

Share one instance between hierarchies whose `Context` has the same `Configuration`. Cached
entries can depend on the configuration, so sharing an instance between different configurations
can resolve the wrong resource variant.

#### Parameters

| | |
| --- | --- |
| initialConfiguration | The `Configuration` of the `Context` that the hierarchies use. Later changes are reported with [onConfigurationChanged](#onconfigurationchanged). |

## Functions

### onConfigurationChanged

> Source set: Android

```kotlin
public fun onConfigurationChanged(newConfiguration: Configuration)
```

Updates the caches for `newConfiguration`. Entries that depend on a changed part of the
configuration are removed. Any change clears the resource id cache.

Calling this again with an unchanged configuration has no effect.

### clear

> Source set: Android

```kotlin
public fun clear()
```

Clears all cached resources, for example in response to `onTrimMemory`.
