# DeletionRequest.Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[Ad Services Extensions 4](https://developer.android.com/sdkExtensions)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/adservices/measurement/DeletionRequest.Builder "View this page in Java")  

```
class Builder
```

|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                   ||
| ↳ | [android.adservices.measurement.DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) |

Builder for[DeletionRequest](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest)objects.

## Summary

|                                                           Public constructors                                                            ||
|---------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#Builder())`()` <br /> |

|                                                                                                                                                                                                                                                                                Public methods                                                                                                                                                                                                                                                                                 ||
|-----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DeletionRequest](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest)                  | [build](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#build())`()` Builds a[DeletionRequest](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest)instance.                                                                                                                                                                               |
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | [setDeletionMode](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#setDeletionMode(kotlin.Int))`(`deletionMode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the match behavior for the supplied params.                                                                                                                                       |
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | [setDomainUris](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#setDomainUris(kotlin.collections.MutableList))`(`domainUris:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!>?`)` Set the list of domain URI which will be used for matching. |
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | [setEnd](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#setEnd(java.time.Instant))`(`end:` `[Instant](https://developer.android.com/reference/kotlin/java/time/Instant.html#)`)` Set the end of the deletion range.                                                                                                                                                                 |
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | [setMatchBehavior](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#setMatchBehavior(kotlin.Int))`(`matchBehavior:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the match behavior for the supplied params.                                                                                                                                    |
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | [setOriginUris](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#setOriginUris(kotlin.collections.MutableList))`(`originUris:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!>?`)` Set the list of origin URI which will be used for matching. |
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | [setStart](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#setStart(java.time.Instant))`(`start:` `[Instant](https://developer.android.com/reference/kotlin/java/time/Instant.html#)`)` Set the start of the deletion range.                                                                                                                                                         |

## Public constructors

### Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[Ad Services Extensions 4](https://developer.android.com/sdkExtensions)  

```
Builder()
```

## Public methods

### build

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[Ad Services Extensions 4](https://developer.android.com/sdkExtensions)  

```
fun build(): DeletionRequest
```

Builds a[DeletionRequest](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest)instance.

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [DeletionRequest](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest) | This value cannot be`null`. |

### setDeletionMode

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[Ad Services Extensions 4](https://developer.android.com/sdkExtensions)  

```
fun setDeletionMode(deletionMode: Int): DeletionRequest.Builder
```

Set the match behavior for the supplied params.[DELETION_MODE_ALL](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest#DELETION_MODE_ALL:kotlin.Int): All data associated with the selected records will be deleted.[DELETION_MODE_EXCLUDE_INTERNAL_DATA](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest#DELETION_MODE_EXCLUDE_INTERNAL_DATA:kotlin.Int): All data except the internal system data (e.g. rate limits) associated with the selected records will be deleted.

|                                                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                                                ||
|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `deletionMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.adservices.measurement.DeletionRequest#DELETION_MODE_ALL](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest#DELETION_MODE_ALL:kotlin.Int), or[android.adservices.measurement.DeletionRequest#DELETION_MODE_EXCLUDE_INTERNAL_DATA](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest#DELETION_MODE_EXCLUDE_INTERNAL_DATA:kotlin.Int) |

|                                                                             Return                                                                             ||
|-----------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | This value cannot be`null`. |

### setDomainUris

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[Ad Services Extensions 4](https://developer.android.com/sdkExtensions)  

```
fun setDomainUris(domainUris: MutableList<Uri!>?): DeletionRequest.Builder
```

Set the list of domain URI which will be used for matching. These will be matched with records using the same domain or any subdomains. E.g. If domainUri is`https://example.com`, then`https://a.example.com`,`https://example.com`and`https://b.example.com`will match;`https://abcexample.com`will NOT match.

|                                                                                                           Parameters                                                                                                            ||
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `domainUris` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!\>?:This value may be`null`. |

|                                                                             Return                                                                             ||
|-----------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | This value cannot be`null`. |

### setEnd

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[Ad Services Extensions 4](https://developer.android.com/sdkExtensions)  

```
fun setEnd(end: Instant): DeletionRequest.Builder
```

Set the end of the deletion range. Passing in[java.time.Instant#MAX](https://developer.android.com/reference/kotlin/java/time/Instant.html#MAX:java.time.Instant)will cause everything from the specified start until the newest record to be deleted. No set end will default to[java.time.Instant#MAX](https://developer.android.com/reference/kotlin/java/time/Instant.html#MAX:java.time.Instant).

|                                                      Parameters                                                      ||
|-------|---------------------------------------------------------------------------------------------------------------|
| `end` | [Instant](https://developer.android.com/reference/kotlin/java/time/Instant.html#):This value cannot be`null`. |

|                                                                             Return                                                                             ||
|-----------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | This value cannot be`null`. |

### setMatchBehavior

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[Ad Services Extensions 4](https://developer.android.com/sdkExtensions)  

```
fun setMatchBehavior(matchBehavior: Int): DeletionRequest.Builder
```

Set the match behavior for the supplied params.[MATCH_BEHAVIOR_DELETE](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest#MATCH_BEHAVIOR_DELETE:kotlin.Int): This option will use the supplied params (Origin URIs \& Domain URIs) for selecting records for deletion.[MATCH_BEHAVIOR_PRESERVE](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest#MATCH_BEHAVIOR_PRESERVE:kotlin.Int): This option will preserve the data associated with the supplied params (Origin URIs \& Domain URIs) and select remaining records for deletion.

|                                                                                                                                                                                                                                                        Parameters                                                                                                                                                                                                                                                        ||
|-----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `matchBehavior` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.adservices.measurement.DeletionRequest#MATCH_BEHAVIOR_DELETE](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest#MATCH_BEHAVIOR_DELETE:kotlin.Int), or[android.adservices.measurement.DeletionRequest#MATCH_BEHAVIOR_PRESERVE](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest#MATCH_BEHAVIOR_PRESERVE:kotlin.Int) |

|                                                                             Return                                                                             ||
|-----------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | This value cannot be`null`. |

### setOriginUris

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[Ad Services Extensions 4](https://developer.android.com/sdkExtensions)  

```
fun setOriginUris(originUris: MutableList<Uri!>?): DeletionRequest.Builder
```

Set the list of origin URI which will be used for matching. These will be matched with records using the same origin only, i.e. subdomains won't match. E.g. If originUri is`https://a.example.com`, then`https://a.example.com`will match;`https://example.com`,`https://b.example.com`and`https://abcexample.com`will NOT match.

|                                                                                                           Parameters                                                                                                            ||
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `originUris` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)!\>?:This value may be`null`. |

|                                                                             Return                                                                             ||
|-----------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | This value cannot be`null`. |

### setStart

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[Ad Services Extensions 4](https://developer.android.com/sdkExtensions)  

```
fun setStart(start: Instant): DeletionRequest.Builder
```

Set the start of the deletion range. Passing in[java.time.Instant#MIN](https://developer.android.com/reference/kotlin/java/time/Instant.html#MIN:java.time.Instant)will cause everything from the oldest record to the specified end be deleted. No set start will default to[java.time.Instant#MIN](https://developer.android.com/reference/kotlin/java/time/Instant.html#MIN:java.time.Instant).

|                                                       Parameters                                                       ||
|---------|---------------------------------------------------------------------------------------------------------------|
| `start` | [Instant](https://developer.android.com/reference/kotlin/java/time/Instant.html#):This value cannot be`null`. |

|                                                                             Return                                                                             ||
|-----------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [DeletionRequest.Builder](https://developer.android.com/reference/kotlin/android/adservices/measurement/DeletionRequest.Builder#) | This value cannot be`null`. |