# BackupActionResult

Artifact: [androidx.test.backup:backup-host](https://developer.android.com/jetpack/androidx/releases/test-backup) [View Source](https://cs.android.com/search?q=file:androidx/test/backup/host/BackupActionResult.kt+class:androidx.test.backup.host.BackupActionResult) Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

*** ** * ** ***


```
public sealed class BackupActionResult
```

<br />

Known direct subclasses [BackupActionResult.Failure](https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Failure), [BackupActionResult.Success](https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Success)

|---|---|
| `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Failure` | Indicates that the device payload failed during execution or verification. |
| `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Success` | Indicates that the device payload executed and verified successfully. |

*** ** * ** ***

Represents the result of a delegated device payload execution.

Note: This sealed class is open to future additions. Consumers should use a non-exhaustive 'when' pattern-matching approach (incorporating an explicit 'else' branch) to ensure binary compatibility when new subclasses are introduced.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Failure extends https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult` Indicates that the device payload failed during execution or verification. |
| `public final class https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Success extends https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult` Indicates that the device payload executed and verified successfully. |

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult#BackupActionResult()()` |

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult#getData()()` Data that the action returned, such as values it read on the device. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult#getOrThrow()()` Returns the `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult#data()` of a `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Success`, or throws an `https://developer.android.com/reference/java/io/IOException.html` for a `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Failure`, as `https://developer.android.com/reference/androidx/test/backup/host/BackupRestoreController#runBackupRestoreFlow(androidx.test.backup.host.StorageDomain,java.nio.file.Path,androidx.test.backup.host.BackupTransportMode,androidx.test.backup.host.BackupRestoreController)` does when one of its actions fails. |
| `final boolean` | `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult#isSuccess()()` Returns true if this is a Success result. |

## Protected constructors

### BackupActionResult

```
protected BackupActionResult()
```

## Public methods

### getData

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public abstract @NonNull Map<@NonNull String, @NonNull String> getData()
```

Data that the action returned, such as values it read on the device. Empty if the action returned none or didn't run to completion. The data of a `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Failure` leaves out the `status` and `error` of the action, which `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Failure#errorMessage()` reports. A result keeps a copy of the data that it's created with.

### getOrThrow

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public final @NonNull Map<@NonNull String, @NonNull String> getOrThrow()
```

Returns the `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult#data()` of a `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Success`, or throws an `https://developer.android.com/reference/java/io/IOException.html` for a `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Failure`, as `https://developer.android.com/reference/androidx/test/backup/host/BackupRestoreController#runBackupRestoreFlow(androidx.test.backup.host.StorageDomain,java.nio.file.Path,androidx.test.backup.host.BackupTransportMode,androidx.test.backup.host.BackupRestoreController)` does when one of its actions fails.

The exception message has the `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Failure#errorMessage()` and the `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Failure#stackTrace()` that the device sent. To read a `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Failure` itself, such as its `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult#data()`, check the type of this result instead.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | if this is a `https://developer.android.com/reference/androidx/test/backup/host/BackupActionResult.Failure` |

### isSuccess

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public final boolean isSuccess()
```

Returns true if this is a Success result.