public static class**CronetEngine.Builder** extends Object  
A builder for[CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html)s, which allows runtime configuration of`CronetEngine`. Configuration options are set on the builder and then[build()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#build())is called to create the`CronetEngine`.  

### Nested Class Summary

|-------|---|---|------------------------------------------------------------------------|
| class | [CronetEngine.Builder.LibraryLoader](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.LibraryLoader.html) || A class which provides a method for loading the cronet native library. |

### Constant Summary

|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| int | [HTTP_CACHE_DISABLED](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#HTTP_CACHE_DISABLED)         | Setting to disable HTTP cache.                               |
| int | [HTTP_CACHE_DISK](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#HTTP_CACHE_DISK)                 | Setting to enable on-disk cache, including HTTP data.        |
| int | [HTTP_CACHE_DISK_NO_HTTP](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#HTTP_CACHE_DISK_NO_HTTP) | Setting to enable on-disk cache, excluding HTTP data.        |
| int | [HTTP_CACHE_IN_MEMORY](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#HTTP_CACHE_IN_MEMORY)       | Setting to enable in-memory HTTP cache, including HTTP data. |

### Public Constructor Summary

|---|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|   | [Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#Builder(android.content.Context))(Context context) Constructs a[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)object that facilitates creating a[CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html). |

### Public Method Summary

|----------------------------------------------------------------------------------------------------------------------------------------| |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [addPublicKeyPins](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#addPublicKeyPins(java.lang.String,%20java.util.Set<byte[]>,%20boolean,%20java.util.Date))(String hostName, Set\<byte\[\]\> pinsSha256, boolean includeSubdomains, Date expirationDate) Pins a set of public keys for a given host.                                                                                                                                                                                                                              |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [addQuicHint](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#addQuicHint(java.lang.String,%20int,%20int))(String host, int port, int alternatePort) Adds hint that`host`supports QUIC.                                                                                                                                                                                                                                                                                                                                            |
| [CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html)                 | [build](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#build())() Build a[CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html)using this builder's configuration.                                                                                                                                                                                                                                                                                                |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [enableBrotli](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableBrotli(boolean))(boolean value) Sets whether[Brotli](https://tools.ietf.org/html/rfc7932)compression is enabled.                                                                                                                                                                                                                                                                                                                                              |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [enableHttp2](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableHttp2(boolean))(boolean value) Sets whether[HTTP/2](https://tools.ietf.org/html/rfc7540)protocol is enabled.                                                                                                                                                                                                                                                                                                                                                   |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [enableHttpCache](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableHttpCache(int,%20long))(int cacheMode, long maxSize) Enables or disables caching of HTTP data and other information like QUIC server information.                                                                                                                                                                                                                                                                                                          |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [enableNetworkQualityEstimator](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableNetworkQualityEstimator(boolean))(boolean value) Enables the network quality estimator, which collects and reports measurements of round trip time (RTT) and downstream throughput at various layers of the network stack.                                                                                                                                                                                                                   |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [enablePublicKeyPinningBypassForLocalTrustAnchors](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enablePublicKeyPinningBypassForLocalTrustAnchors(boolean))(boolean value) Enables or disables public key pinning bypass for local trust anchors.                                                                                                                                                                                                                                                                                |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [enableQuic](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableQuic(boolean))(boolean value) Sets whether[QUIC](https://www.chromium.org/quic)protocol is enabled.                                                                                                                                                                                                                                                                                                                                                             |
| String                                                                                                                                 | [getDefaultUserAgent](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#getDefaultUserAgent())() Constructs a User-Agent string including application name and version, system build version, model and id, and Cronet version.                                                                                                                                                                                                                                                                                                      |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [setConnectionMigrationOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setConnectionMigrationOptions(org.chromium.net.ConnectionMigrationOptions))([ConnectionMigrationOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.html)connectionMigrationOptions) Configures the behavior of connection migration.                                                                                                                                         |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [setConnectionMigrationOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setConnectionMigrationOptions(org.chromium.net.ConnectionMigrationOptions.Builder))([ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)connectionMigrationOptionsBuilder)                                                                                                                                                           |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [setDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setDnsOptions(org.chromium.net.DnsOptions.Builder))([DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html)dnsOptions)                                                                                                                                                                                                                                                                  |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [setDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setDnsOptions(org.chromium.net.DnsOptions))([DnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html)dnsOptions) Configures the behavior of hostname lookup.                                                                                                                                                                                                                                              |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [setLibraryLoader](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setLibraryLoader(org.chromium.net.CronetEngine.Builder.LibraryLoader))([CronetEngine.Builder.LibraryLoader](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.LibraryLoader.html)loader) Sets a[CronetEngine.Builder.LibraryLoader](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.LibraryLoader.html)to be used to load the native library. |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [setQuicOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setQuicOptions(org.chromium.net.QuicOptions.Builder))([QuicOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/QuicOptions.Builder.html)quicOptionsBuilder)                                                                                                                                                                                                                                                     |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [setQuicOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setQuicOptions(org.chromium.net.QuicOptions))([QuicOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/QuicOptions.html)quicOptions) Configures the behavior of Cronet when using QUIC.                                                                                                                                                                                                                                 |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [setStoragePath](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setStoragePath(java.lang.String))(String value) Sets directory for HTTP Cache and Cookie Storage.                                                                                                                                                                                                                                                                                                                                                                 |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [setThreadPriority](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setThreadPriority(int))(int priority) Sets the thread priority of Cronet's internal thread.                                                                                                                                                                                                                                                                                                                                                                    |
| [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) | [setUserAgent](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setUserAgent(java.lang.String))(String userAgent) Overrides the User-Agent header for all requests.                                                                                                                                                                                                                                                                                                                                                                 |

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

## Constants

#### public static final int**HTTP_CACHE_DISABLED**

Setting to disable HTTP cache. Some data may still be temporarily stored in memory. Passed to[enableHttpCache(int, long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableHttpCache(int,%20long)).  
Constant Value:0  

#### public static final int**HTTP_CACHE_DISK**

Setting to enable on-disk cache, including HTTP data.[setStoragePath(String)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setStoragePath(java.lang.String))must be called prior to passing this constant to[enableHttpCache(int, long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableHttpCache(int,%20long)).  
Constant Value:3  

#### public static final int**HTTP_CACHE_DISK_NO_HTTP**

Setting to enable on-disk cache, excluding HTTP data.[setStoragePath(String)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setStoragePath(java.lang.String))must be called prior to passing this constant to[enableHttpCache(int, long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableHttpCache(int,%20long)).  
Constant Value:2  

#### public static final int**HTTP_CACHE_IN_MEMORY**

Setting to enable in-memory HTTP cache, including HTTP data. Passed to[enableHttpCache(int, long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableHttpCache(int,%20long)).  
Constant Value:1

## Public Constructors

#### public**Builder**(Context context)

Constructs a[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)object that facilitates creating a[CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html). The default configuration enables HTTP/2 and QUIC, but disables the HTTP cache.  

##### Parameters

| context | Android[Context](https://developer.android.com/develop/connectivity/cronet/reference/android/content/Context.html), which is used by[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)to retrieve the application context. A reference to only the application context will be kept, so as to avoid extending the lifetime of`context`unnecessarily. |
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

## Public Methods

#### public[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)**addPublicKeyPins**(String hostName, Set\<byte\[\]\> pinsSha256, boolean includeSubdomains, Date expirationDate)

Pins a set of public keys for a given host. By pinning a set of public keys,`pinsSha256`, communication with`hostName`is required to authenticate with a certificate with a public key from the set of pinned ones. An app can pin the public key of the root certificate, any of the intermediate certificates or the end-entry certificate. Authentication will fail and secure communication will not be established if none of the public keys is present in the host's certificate chain, even if the host attempts to authenticate with a certificate allowed by the device's trusted store of certificates.

Calling this method multiple times with the same host name overrides the previously set pins for the host.

More information about the public key pinning can be found in[RFC 7469](https://tools.ietf.org/html/rfc7469).  

##### Parameters

|     hostName      |                                                                                                                                                                                                                                                                                 name of the host to which the public keys should be pinned. A host that consists only of digits and the dot character is treated as invalid.                                                                                                                                                                                                                                                                                 |
|    pinsSha256     | a set of pins. Each pin is the SHA-256 cryptographic hash of the DER-encoded ASN.1 representation of the Subject Public Key Info (SPKI) of the host's X.509 certificate. Use[Certificate.getPublicKey()](https://developer.android.com/develop/connectivity/cronet/reference/java/security/cert/Certificate.html#getPublicKey())and[Key.getEncoded()](https://developer.android.com/develop/connectivity/cronet/reference/java/security/Key.html#getEncoded())to obtain DER-encoded ASN.1 representation of the SPKI. Although, the method does not mandate the presence of the backup pin that can be used if the control of the primary private key has been lost, it is highly recommended to supply one. |
| includeSubdomains |                                                                                                                                                                                                                                                                                                              indicates whether the pinning policy should be applied to subdomains of`hostName`.                                                                                                                                                                                                                                                                                                              |
|  expirationDate   |                                                                                                                                                                                                                                                                                                                                 specifies the expiration date for the pins.                                                                                                                                                                                                                                                                                                                                  |
|-------------------| |

##### Returns

- the builder to facilitate chaining.  

##### Throws

|   NullPointerException   |                                      if any of the input parameters are`null`.                                      |
| IllegalArgumentException | if the given host name is invalid or`pinsSha256`contains a byte array that does not represent a valid SHA-256 hash. |
|--------------------------|---------------------------------------------------------------------------------------------------------------------|

#### public[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)**addQuicHint**(String host, int port, int alternatePort)

Adds hint that`host`supports QUIC. Note that[enableHttpCache](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableHttpCache(int,%20long))([HTTP_CACHE_DISK](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#HTTP_CACHE_DISK)) is needed to take advantage of 0-RTT connection establishment between sessions.  

##### Parameters

|     host      | hostname of the server that supports QUIC. |
|     port      |   host of the server that supports QUIC.   |
| alternatePort |      alternate port to use for QUIC.       |
|---------------|--------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

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

Build a[CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html)using this builder's configuration.  

##### Returns

- constructed[CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html).  

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

Sets whether[Brotli](https://tools.ietf.org/html/rfc7932)compression is enabled. If enabled, Brotli will be advertised in Accept-Encoding request headers. Defaults to disabled.  

##### Parameters

| value | `true`to enable Brotli,`false`to disable. |
|-------|-------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

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

Sets whether[HTTP/2](https://tools.ietf.org/html/rfc7540)protocol is enabled. Defaults to enabled.  

##### Parameters

| value | `true`to enable HTTP/2,`false`to disable. |
|-------|-------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

#### public[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)**enableHttpCache**(int cacheMode, long maxSize)

Enables or disables caching of HTTP data and other information like QUIC server information.  

##### Parameters

| cacheMode | control location and type of cached data. Must be one of[HTTP_CACHE_*](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#HTTP_CACHE_DISABLED). |
|  maxSize  |                                                              maximum size in bytes used to cache data (advisory and maybe exceeded at times).                                                               |
|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

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

Enables the network quality estimator, which collects and reports measurements of round trip time (RTT) and downstream throughput at various layers of the network stack. After enabling the estimator, listeners of RTT and throughput can be added with[CronetEngine.addRttListener(NetworkQualityRttListener)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#addRttListener(org.chromium.net.NetworkQualityRttListener))and[CronetEngine.addThroughputListener(NetworkQualityThroughputListener)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#addThroughputListener(org.chromium.net.NetworkQualityThroughputListener))and removed with[CronetEngine.removeRttListener(NetworkQualityRttListener)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#removeRttListener(org.chromium.net.NetworkQualityRttListener))and[CronetEngine.removeThroughputListener(NetworkQualityThroughputListener)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#removeThroughputListener(org.chromium.net.NetworkQualityThroughputListener)). The estimator uses memory and CPU only when enabled.  

##### Parameters

| value | `true`to enable network quality estimator,`false`to disable. |
|-------|--------------------------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

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

Enables or disables public key pinning bypass for local trust anchors. Disabling the bypass for local trust anchors is highly discouraged since it may prohibit the app from communicating with the pinned hosts. E.g., a user may want to send all traffic through an SSL enabled proxy by changing the device proxy settings and adding the proxy certificate to the list of local trust anchor. Disabling the bypass will most likely prevent the app from sending any traffic to the pinned hosts. For more information see 'How does key pinning interact with local proxies and filters?' at https://www.chromium.org/Home/chromium-security/security-faq  

##### Parameters

| value | `true`to enable the bypass,`false`to disable. |
|-------|-----------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

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

Sets whether[QUIC](https://www.chromium.org/quic)protocol is enabled. Defaults to enabled. If QUIC is enabled, then QUIC User Agent Id containing application name and Cronet version is sent to the server.  

##### Parameters

| value | `true`to enable QUIC,`false`to disable. |
|-------|-----------------------------------------|

##### Returns

- the builder to facilitate chaining.  

#### public String**getDefaultUserAgent**()

Constructs a User-Agent string including application name and version, system build version, model and id, and Cronet version.  

##### Returns

- User-Agent string.  

#### public[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)**setConnectionMigrationOptions**([ConnectionMigrationOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.html)connectionMigrationOptions)

Configures the behavior of connection migration. For more details, see documentation of[ConnectionMigrationOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.html)and the individual methods of[ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html).

Only relevant if[enableQuic(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableQuic(boolean))is enabled.  

##### Parameters

| connectionMigrationOptions |   |
|----------------------------|---|

##### Returns

- the builder to facilitate chaining.  

#### public[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)**setConnectionMigrationOptions**([ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)connectionMigrationOptionsBuilder)

<br />

##### Parameters

| connectionMigrationOptionsBuilder |   |
|-----------------------------------|---|

##### See Also

- [setConnectionMigrationOptions(ConnectionMigrationOptions)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setConnectionMigrationOptions(org.chromium.net.ConnectionMigrationOptions))  

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

<br />

##### Parameters

| dnsOptions |   |
|------------|---|

##### See Also

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

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

Configures the behavior of hostname lookup. For more details, see documentation of[DnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.html)and the individual methods of[DnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.Builder.html).

Only relevant if[enableQuic(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableQuic(boolean))is enabled.  

##### Parameters

| dnsOptions |   |
|------------|---|

##### Returns

- the builder to facilitate chaining.  

#### public[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)**setLibraryLoader**([CronetEngine.Builder.LibraryLoader](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.LibraryLoader.html)loader)

Sets a[CronetEngine.Builder.LibraryLoader](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.LibraryLoader.html)to be used to load the native library. If not set, the library will be loaded using[System.loadLibrary(String)](https://developer.android.com/develop/connectivity/cronet/reference/java/lang/System.html#loadLibrary(java.lang.String)).  

##### Parameters

| loader | `LibraryLoader`to be used to load the native library. |
|--------|-------------------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

#### public[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)**setQuicOptions**([QuicOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/QuicOptions.Builder.html)quicOptionsBuilder)

<br />

##### Parameters

| quicOptionsBuilder |   |
|--------------------|---|

##### See Also

- [setQuicOptions(QuicOptions)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#setQuicOptions(org.chromium.net.QuicOptions))  

#### public[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)**setQuicOptions**([QuicOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/QuicOptions.html)quicOptions)

Configures the behavior of Cronet when using QUIC. For more details, see documentation of[QuicOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/QuicOptions.html)and the individual methods of[QuicOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/QuicOptions.Builder.html).

Only relevant if[enableQuic(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableQuic(boolean))is enabled.  

##### Parameters

| quicOptions |   |
|-------------|---|

##### Returns

- the builder to facilitate chaining.  

#### public[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)**setStoragePath**(String value)

Sets directory for HTTP Cache and Cookie Storage. The directory must exist.

**NOTE:** Do not use the same storage directory with more than one`CronetEngine`at a time. Access to the storage directory does not support concurrent access by multiple`CronetEngine`s.  

##### Parameters

| value | path to existing directory. |
|-------|-----------------------------|

##### Returns

- the builder to facilitate chaining.  

#### public[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)**setThreadPriority**(int priority)

Sets the thread priority of Cronet's internal thread.  

##### Parameters

| priority | the thread priority of Cronet's internal thread. A Linux priority level, from -20 for highest scheduling priority to 19 for lowest scheduling priority. For more information on values, see[Process.setThreadPriority(int, int)](https://developer.android.com/develop/connectivity/cronet/reference/android/os/Process.html#setThreadPriority(int,%20int))and[THREAD_PRIORITY_*](https://developer.android.com/develop/connectivity/cronet/reference/android/os/Process.html#THREAD_PRIORITY_DEFAULT)values. |
|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

##### Returns

- the builder to facilitate chaining.  

#### public[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html)**setUserAgent**(String userAgent)

Overrides the User-Agent header for all requests. An explicitly set User-Agent header (set using[UrlRequest.Builder.addHeader(String, String)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html#addHeader(java.lang.String,%20java.lang.String))) will override a value set using this function.  

##### Parameters

| userAgent | the User-Agent string to use for all requests. |
|-----------|------------------------------------------------|

##### Returns

- the builder to facilitate chaining.