# ExistingWorkPolicy

Artifact: [androidx.work:work-runtime](https://developer.android.com/jetpack/androidx/releases/work) [View Source](https://cs.android.com/search?q=file:androidx/work/ExistingWorkPolicy.kt+class:androidx.work.ExistingWorkPolicy) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

*** ** * ** ***


```
enum ExistingWorkPolicy : Enum<ExistingWorkPolicy>
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [kotlin.Enum](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-enum/index.html)\<[ExistingWorkPolicy](https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy)\> ||
|   | ↳ | [androidx.work.ExistingWorkPolicy](https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy) |

*** ** * ** ***

An enumeration of the conflict resolution policies available to unique `https://developer.android.com/reference/kotlin/androidx/work/OneTimeWorkRequest`s in case of a collision.

## Summary

| ### Enum Values |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy#APPEND` | If there is existing pending (uncompleted) work with the same unique name, append the newly-specified work as a child of all the leaves of that work sequence. |
| `https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy#APPEND_OR_REPLACE` | If there is existing pending (uncompleted) work with the same unique name, append the newly-specified work as the child of all the leaves of that work sequence. |
| `https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy#KEEP` | If there is existing pending (uncompleted) work with the same unique name, do nothing. |
| `https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy#REPLACE` | If there is existing pending (uncompleted) work with the same unique name, cancel and delete it. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy` | `https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy#valueOf(kotlin.String)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Returns the enum constant of this type with the specified name. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy>` | `https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy#values()()` Returns an array containing the constants of this enum type, in the order they're declared. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html<https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy>` | `https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy#entries()` Returns an immutable `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html` list containing the constants of this enum type, in the order they're declared. |

## Enum Values

### APPEND

```
val ExistingWorkPolicy.APPEND: ExistingWorkPolicy
```

If there is existing pending (uncompleted) work with the same unique name, append the newly-specified work as a child of all the leaves of that work sequence. Otherwise, insert the newly-specified work as the start of a new sequence.

**Note:** When using APPEND with failed or cancelled prerequisites, newly enqueued work will also be marked as failed or cancelled respectively. Use `https://developer.android.com/reference/kotlin/androidx/work/ExistingWorkPolicy#APPEND_OR_REPLACE` to create a new chain of work.

### APPEND_OR_REPLACE

```
val ExistingWorkPolicy.APPEND_OR_REPLACE: ExistingWorkPolicy
```

If there is existing pending (uncompleted) work with the same unique name, append the newly-specified work as the child of all the leaves of that work sequence. Otherwise, insert the newly-specified work as the start of a new sequence.

**Note:** If there are failed or cancelled prerequisites, these prerequisites are *dropped* and the newly-specified work is the start of a new sequence.

### KEEP

```
val ExistingWorkPolicy.KEEP: ExistingWorkPolicy
```

If there is existing pending (uncompleted) work with the same unique name, do nothing. Otherwise, insert the newly-specified work.

### REPLACE

```
val ExistingWorkPolicy.REPLACE: ExistingWorkPolicy
```

If there is existing pending (uncompleted) work with the same unique name, cancel and delete it. Then, insert the newly-specified work.

## Public functions

### valueOf

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

```
fun valueOf(value: String): ExistingWorkPolicy
```

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if this enum type has no constant with the specified name |

### values

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

```
fun values(): Array<ExistingWorkPolicy>
```

Returns an array containing the constants of this enum type, in the order they're declared.

This method may be used to iterate over the constants.

The function returns a new instance of the array on every call. The array could be mutated, so working with it may also require defensive copying. Consider using `entries` property as a more efficient alternative returning an immutable list of enum entries.

## Public properties

### entries

```
val entries: EnumEntries<ExistingWorkPolicy>
```

Returns an immutable `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html` list containing the constants of this enum type, in the order they're declared.