# PlatformTestStorageRegistry

Artifact: [androidx.test:monitor](https://developer.android.com/jetpack/androidx/releases/test) [View Source](https://cs.android.com/search?q=file:androidx/test/platform/io/PlatformTestStorageRegistry.java+class:androidx.test.platform.io.PlatformTestStorageRegistry)

*** ** * ** ***


```
public final class PlatformTestStorageRegistry
```

<br />

*** ** * ** ***

A registry instance that holds a reference to an `PlatformTestStorage` instance.

Users should use this to retrieve the appropriate `https://developer.android.com/reference/androidx/test/platform/io/PlatformTestStorage` for the current execution environment.

## Summary

| ### Public methods |
|---|---|
| `synchronized static https://developer.android.com/reference/androidx/test/platform/io/PlatformTestStorage` | `https://developer.android.com/reference/androidx/test/platform/io/PlatformTestStorageRegistry#getInstance()()` Returns the registered `PlatformTestStorage` instance. |
| `synchronized static void` | `https://developer.android.com/reference/androidx/test/platform/io/PlatformTestStorageRegistry#registerInstance(androidx.test.platform.io.PlatformTestStorage)(https://developer.android.com/reference/androidx/test/platform/io/PlatformTestStorage instance)` Registers a new `PlatformTestStorage` instance. |

## Public methods

### getInstance

```
synchronized public static PlatformTestStorage getInstance()
```

Returns the registered `PlatformTestStorage` instance.

By default, a `https://developer.android.com/reference/androidx/test/platform/io/FileTestStorage` implementation is used. The default implementation is currently recommended for users using android gradle plugins version 8.0 or greater which supports writing output files (only). Gradle users using versions 8.0 or greater can optionally also opt in the test services TestStorage implementation by adding the following configuration to their build.gradle file: `
defaultConfig { testInstrumentationRunnerArguments useTestStorageService: "true" }
dependencies { androidTestUtil "androidx.test.services:test-services:$servicesVersion" }
`

This method returns the instance last registered by the `https://developer.android.com/reference/androidx/test/platform/io/PlatformTestStorageRegistry#registerInstance(androidx.test.platform.io.PlatformTestStorage)` method, or the default instance if none is ever registered. Advanced users can provide `https://developer.android.com/reference/java/util/ServiceLoader.html` metadata to provide an alternate implementation to load.

### registerInstance

```
synchronized public static void registerInstance(PlatformTestStorage instance)
```

Registers a new `PlatformTestStorage` instance. This will override any previously set instance.

Users should not typically call this directly - it is intended for use by the test infrastructure.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/test/platform/io/PlatformTestStorage instance` | the instance to be registered. Cannot be null. |