public static final class**DnsOptions.Builder** extends Object  
Builder for[DnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html).  

### Public Method Summary

|------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html)                 | [build](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#build())() Creates and returns the final[DnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html)instance, based on the values in this builder.                                                                                                                                                                                         |
| [DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html) | [enableStaleDns](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#enableStaleDns(boolean))(boolean enable) Sets whether to use stale DNS results at all.                                                                                                                                                                                                                                                                                                  |
| [DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html) | [persistHostCache](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#persistHostCache(boolean))(boolean persistHostCache) Sets whether the DNS cache should be persisted to disk.                                                                                                                                                                                                                                                                          |
| [DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html) | [preestablishConnectionsToStaleDnsResults](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#preestablishConnectionsToStaleDnsResults(boolean))(boolean enable) Sets whether Cronet should use stale cached DNS records to pre-establish connections.                                                                                                                                                                                                      |
| [DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html) | [setPersistDelay](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#setPersistDelay(java.time.Duration))(Duration persistToDiskPeriod) Same as[setPersistHostCachePeriodMillis(long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#setPersistHostCachePeriodMillis(long))but using[Duration](https://developer.android.com/develop/connectivity/cronet/reference/java/time/Duration.html). |
| [DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html) | [setPersistHostCachePeriodMillis](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#setPersistHostCachePeriodMillis(long))(long persistHostCachePeriodMillis) Sets the minimum period between subsequent writes to disk for DNS cache persistence.                                                                                                                                                                                                         |
| [DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html) | [setStaleDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#setStaleDnsOptions(org.chromium.net.DnsOptions.StaleDnsOptions.Builder))([DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)staleDnsOptionsBuilder)                                                                                                                  |
| [DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html) | [setStaleDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#setStaleDnsOptions(org.chromium.net.DnsOptions.StaleDnsOptions))([DnsOptions.StaleDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.html)staleDnsOptions) Sets detailed configuration for stale DNS.                                                                                                      |
| [DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html) | [useBuiltInDnsResolver](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#useBuiltInDnsResolver(boolean))(boolean enable)                                                                                                                                                                                                                                                                                                                                  |

### Inherited Method Summary

From class java.lang.Object  

|------------------|---------------------------|
| Object           | clone()                   |
| boolean          | equals(Object arg0)       |
| void             | finalize()                |
| final Class\<?\> | getClass()                |
| int              | hashCode()                |
| final void       | notify()                  |
| final void       | notifyAll()               |
| String           | toString()                |
| final void       | wait(long arg0, int arg1) |
| final void       | wait(long arg0)           |
| final void       | wait()                    |

## Public Methods

#### public[DnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html)**build**()

Creates and returns the final[DnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html)instance, based on the values in this builder.  

#### public[DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html)**enableStaleDns**(boolean enable)

Sets whether to use stale DNS results at all.  

##### Parameters

| enable |   |
|--------|---|

##### Returns

- the builder for chaining  

#### public[DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html)**persistHostCache**(boolean persistHostCache)

Sets whether the DNS cache should be persisted to disk.

Only relevant if[CronetEngine.Builder.setStoragePath(String)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setStoragePath(java.lang.String))is set.  

##### Parameters

| persistHostCache |   |
|------------------|---|

##### Returns

- the builder for chaining  

#### public[DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html)**preestablishConnectionsToStaleDnsResults**(boolean enable)

Sets whether Cronet should use stale cached DNS records to pre-establish connections.

If enabled, Cronet will optimistically pre-establish connections to servers that matched the hostname at some point in the past and were cached but the cache entry expired. Such connections won't be used further until a new DNS lookup confirms the cached record was up to date.

To use cached DNS records straight away, use[enableStaleDns(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#enableStaleDns(boolean))and[DnsOptions.StaleDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.html)configuration options.

This option may not be available for all networking protocols.  

##### Parameters

| enable |   |
|--------|---|

##### Returns

- the builder for chaining  

#### public[DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html)**setPersistDelay**(Duration persistToDiskPeriod)

Same as[setPersistHostCachePeriodMillis(long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#setPersistHostCachePeriodMillis(long))but using[Duration](https://developer.android.com/develop/connectivity/cronet/reference/java/time/Duration.html).  

##### Parameters

| persistToDiskPeriod |   |
|---------------------|---|

##### Returns

- the builder for chaining  

#### public[DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html)**setPersistHostCachePeriodMillis**(long persistHostCachePeriodMillis)

Sets the minimum period between subsequent writes to disk for DNS cache persistence.

Only relevant if[persistHostCache(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#persistHostCache(boolean))is set to true.  

##### Parameters

| persistHostCachePeriodMillis |   |
|------------------------------|---|

##### Returns

- the builder for chaining  

#### public[DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html)**setStaleDnsOptions**([DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)staleDnsOptionsBuilder)

<br />

##### Parameters

| staleDnsOptionsBuilder |   |
|------------------------|---|

##### See Also

- [setStaleDnsOptions(StaleDnsOptions)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#setStaleDnsOptions(org.chromium.net.DnsOptions.StaleDnsOptions))  

#### public[DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html)**setStaleDnsOptions**([DnsOptions.StaleDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.html)staleDnsOptions)

Sets detailed configuration for stale DNS. Only relevant if[enableStaleDns(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html#enableStaleDns(boolean))is set.  

##### Parameters

| staleDnsOptions |   |
|-----------------|---|

##### Returns

- this builder for chaining.  

#### public[DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html)**useBuiltInDnsResolver**(boolean enable)

<br />

##### Parameters

| enable |   |
|--------|---|