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

*** ** * ** ***


```
public enum ExistingWorkPolicy extends Enum<@NonNull ExistingWorkPolicy>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [kotlin.Enum](https://developer.android.com/reference/java/lang/Enum.html)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) [ExistingWorkPolicy](https://developer.android.com/reference/androidx/work/ExistingWorkPolicy)\> ||
|   | ↳ | [androidx.work.ExistingWorkPolicy](https://developer.android.com/reference/androidx/work/ExistingWorkPolicy) |

*** ** * ** ***

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

## Summary

| ### Enum Values |
|---|---|
| `https://developer.android.com/reference/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/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/androidx/work/ExistingWorkPolicy#KEEP` | If there is existing pending (uncompleted) work with the same unique name, do nothing. |
| `https://developer.android.com/reference/androidx/work/ExistingWorkPolicy#REPLACE` | If there is existing pending (uncompleted) work with the same unique name, cancel and delete it. |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ExistingWorkPolicy>` | `https://developer.android.com/reference/androidx/work/ExistingWorkPolicy#getEntries()()` 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. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/ExistingWorkPolicy` | `https://developer.android.com/reference/androidx/work/ExistingWorkPolicy#valueOf(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value)` Returns the enum constant of this type with the specified name. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull ExistingWorkPolicy[]` | `https://developer.android.com/reference/androidx/work/ExistingWorkPolicy#values()()` Returns an array containing the constants of this enum type, in the order they're declared. |

## Enum Values

### APPEND

```
ExistingWorkPolicy 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. 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/androidx/work/ExistingWorkPolicy#APPEND_OR_REPLACE` to create a new chain of work.

### APPEND_OR_REPLACE

```
ExistingWorkPolicy 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. 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

```
ExistingWorkPolicy ExistingWorkPolicy.KEEP
```

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

### REPLACE

```
ExistingWorkPolicy ExistingWorkPolicy.REPLACE
```

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

## Public methods

### getEntries

```
public final @NonNull EnumEntries<@NonNull ExistingWorkPolicy> getEntries()
```

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.

### valueOf

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

```
public static final @NonNull ExistingWorkPolicy valueOf(@NonNull String value)
```

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)

```
public static final @NonNull ExistingWorkPolicy[] values()
```

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.