# PlatformTestStorageRegistry

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/test/platform/io/PlatformTestStorageRegistry "View this page in Java")

<br />

```
class PlatformTestStorageRegistry
```

<br />

*** ** * ** ***

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

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

## Summary

|                                                               ### Public functions                                                                |
|---------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `synchronized java-static `[PlatformTestStorage](https://developer.android.com/reference/kotlin/androidx/test/platform/io/PlatformTestStorage)`!` | [getInstance](https://developer.android.com/reference/kotlin/androidx/test/platform/io/PlatformTestStorageRegistry#getInstance())`()` Returns the registered`PlatformTestStorage`instance.                                                                                                                                                                                 |
| `synchronized java-static `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                          | [registerInstance](https://developer.android.com/reference/kotlin/androidx/test/platform/io/PlatformTestStorageRegistry#registerInstance(androidx.test.platform.io.PlatformTestStorage))`(instance: `[PlatformTestStorage](https://developer.android.com/reference/kotlin/androidx/test/platform/io/PlatformTestStorage)`!)` Registers a new`PlatformTestStorage`instance. |

## Public functions

### getInstance

```
synchronized java-static fun getInstance(): PlatformTestStorage!
```

Returns the registered`PlatformTestStorage`instance.

By default, a[FileTestStorage](https://developer.android.com/reference/kotlin/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[registerInstance](https://developer.android.com/reference/kotlin/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[java.util.ServiceLoader](https://developer.android.com/reference/java/util/ServiceLoader.html)metadata to provide an alternate implementation to load.  

### registerInstance

```
synchronized java-static fun registerInstance(instance: PlatformTestStorage!): Unit
```

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                                                             |
|------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| `instance: `[PlatformTestStorage](https://developer.android.com/reference/kotlin/androidx/test/platform/io/PlatformTestStorage)`!` | the instance to be registered. Cannot be null. |