# PagedList.Config.Builder

# PagedList.Config.Builder

Artifact:[androidx.paging:paging-common](https://developer.android.com/jetpack/androidx/releases/paging)  
[View Source](https://cs.android.com/search?q=file:androidx/paging/PagedList.kt+class:androidx.paging.PagedList.Config.Builder)  
Added in[2.0.0](https://developer.android.com/jetpack/androidx/releases/paging#2.0.0)  
Deprecated in[3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/paging/PagedList.Config.Builder "View this page in Java")
Common/AllAndroid/JVMNative/C/iOSJavaScript
  - android  

  ```
  class PagedList.Config.Builder
  ```

*** ** * ** ***

| **This class is deprecated.**   
| PagedList is deprecated and has been replaced by PagingData

Builder class for[PagedList.Config](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config).

You must at minimum specify page size with[setPageSize](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setPageSize(kotlin.Int)).

## Summary

|                                                                                             ### Public constructors                                                                                              |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| ~~[Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#Builder())~~`()` **This function is deprecated.**PagedList is deprecated and has been replaced by PagingData | android |

|                                                ### Public functions                                                 |
|---------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
| [PagedList.Config](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config)                 | ~~[build](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#build())~~`()` **This function is deprecated.**PagedList is deprecated and has been replaced by PagingData                                                                                                                                                                                                                                                    | android |
| [PagedList.Config.Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder) | ~~[setEnablePlaceholders](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setEnablePlaceholders(kotlin.Boolean))~~`(enablePlaceholders: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` **This function is deprecated.**PagedList is deprecated and has been replaced by PagingData                                                                                             | android |
| [PagedList.Config.Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder) | ~~[setInitialLoadSizeHint](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setInitialLoadSizeHint(kotlin.Int))~~`(initialLoadSizeHint: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` **This function is deprecated.**PagedList is deprecated and has been replaced by PagingData | android |
| [PagedList.Config.Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder) | ~~[setMaxSize](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setMaxSize(kotlin.Int))~~`(maxSize: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 2) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` **This function is deprecated.**PagedList is deprecated and has been replaced by PagingData                                     | android |
| [PagedList.Config.Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder) | ~~[setPageSize](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setPageSize(kotlin.Int))~~`(pageSize: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` **This function is deprecated.**PagedList is deprecated and has been replaced by PagingData                                  | android |
| [PagedList.Config.Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder) | ~~[setPrefetchDistance](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setPrefetchDistance(kotlin.Int))~~`(prefetchDistance: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` **This function is deprecated.**PagedList is deprecated and has been replaced by PagingData          | android |

## Public constructors

### Builder

android  
Added in[2.0.0](https://developer.android.com/jetpack/androidx/releases/paging#2.0.0)  
Deprecated in[3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)  

```
[Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#Builder())()
```
| **This function is deprecated.**   
| PagedList is deprecated and has been replaced by PagingData

## Public functions

### build

android  
Added in[2.0.0](https://developer.android.com/jetpack/androidx/releases/paging#2.0.0)  
Deprecated in[3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)  

```
fun [build](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#build())(): PagedList.Config
```
| **This function is deprecated.**   
| PagedList is deprecated and has been replaced by PagingData

Creates a[PagedList.Config](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config)with the given parameters.  

|                                               Returns                                               |
|-----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------|
| [PagedList.Config](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config) | A new[PagedList.Config](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config). |

|                                                             Throws                                                             |
|--------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| [kotlin.IllegalArgumentException](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html) | if placeholders are disabled and prefetchDistance is set to 0 |
| [kotlin.IllegalArgumentException](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html) | if maximum size is less than pageSize + 2\*prefetchDistance   |

### setEnablePlaceholders

android  
Added in[2.0.0](https://developer.android.com/jetpack/androidx/releases/paging#2.0.0)  
Deprecated in[3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)  

```
fun [setEnablePlaceholders](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setEnablePlaceholders(kotlin.Boolean))(enablePlaceholders: Boolean): PagedList.Config.Builder
```
| **This function is deprecated.**   
| PagedList is deprecated and has been replaced by PagingData

Pass false to disable null placeholders in[PagedList](https://developer.android.com/reference/kotlin/androidx/paging/PagedList)s using this[PagedList.Config](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config).

If not set, defaults to true.

A[PagedList](https://developer.android.com/reference/kotlin/androidx/paging/PagedList)will present null placeholders for not-yet-loaded content if two conditions are met:

1. Its[PagingSource](https://developer.android.com/reference/kotlin/androidx/paging/PagingSource)can count all unloaded items (so that the number of nulls to present is known).

2. placeholders are not disabled on the[PagedList.Config](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config).

Call`setEnablePlaceholders(false)`to ensure the receiver of the PagedList (often a[androidx.paging.PagedListAdapter](https://developer.android.com/reference/kotlin/androidx/paging/PagedListAdapter)) doesn't need to account for null items.

If placeholders are disabled, not-yet-loaded content will not be present in the list. Paging will still occur, but as items are loaded or removed, they will be signaled as inserts to the[PagedList.Callback](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Callback).

[PagedList.Callback.onChanged](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Callback#onChanged(kotlin.Int,kotlin.Int))will not be issued as part of loading, though a[androidx.paging.PagedListAdapter](https://developer.android.com/reference/kotlin/androidx/paging/PagedListAdapter)may still receive change events as a result of[PagedList](https://developer.android.com/reference/kotlin/androidx/paging/PagedList)diffing.  

|                                                Parameters                                                 |
|-----------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| `enablePlaceholders: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `false`if null placeholders should be disabled. |

|                                                       Returns                                                       |
|---------------------------------------------------------------------------------------------------------------------|------|
| [PagedList.Config.Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder) | this |

### setInitialLoadSizeHint

android  
Added in[2.0.0](https://developer.android.com/jetpack/androidx/releases/paging#2.0.0)  
Deprecated in[3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)  

```
fun [setInitialLoadSizeHint](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setInitialLoadSizeHint(kotlin.Int))(initialLoadSizeHint: @IntRange(from = 1) Int): PagedList.Config.Builder
```
| **This function is deprecated.**   
| PagedList is deprecated and has been replaced by PagingData

Defines how many items to load when first load occurs.

This value is typically larger than page size, so on first load data there's a large enough range of content loaded to cover small scrolls.

If not set, defaults to three times page size.  

|                                                                                               Parameters                                                                                                |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| `initialLoadSizeHint: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Number of items to load while initializing the[PagedList](https://developer.android.com/reference/kotlin/androidx/paging/PagedList) |

|                                                       Returns                                                       |
|---------------------------------------------------------------------------------------------------------------------|------|
| [PagedList.Config.Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder) | this |

### setMaxSize

android  
Added in[2.1.0](https://developer.android.com/jetpack/androidx/releases/paging#2.1.0)  
Deprecated in[3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)  

```
fun [setMaxSize](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setMaxSize(kotlin.Int))(maxSize: @IntRange(from = 2) Int): PagedList.Config.Builder
```
| **This function is deprecated.**   
| PagedList is deprecated and has been replaced by PagingData

Defines how many items to keep loaded at once.

This can be used to cap the number of items kept in memory by dropping pages. This value is typically many pages so old pages are cached in case the user scrolls back.

This value must be at least two times the[prefetchDistance](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setPrefetchDistance(kotlin.Int))plus the[pageSize](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setPageSize(kotlin.Int))). This constraint prevent loads from being continuously fetched and discarded due to prefetching.

The max size specified here best effort, not a guarantee. In practice, if[maxSize](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setMaxSize(kotlin.Int))is many times the page size, the number of items held by the[PagedList](https://developer.android.com/reference/kotlin/androidx/paging/PagedList)will not grow above this number. Exceptions are made as necessary to guarantee:

- Pages are never dropped until there are more than two pages loaded. Note that a[PagingSource](https://developer.android.com/reference/kotlin/androidx/paging/PagingSource)may not be held strictly to[requested pageSize](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config#pageSize()), so two pages may be larger than expected.

- Pages are never dropped if they are within a prefetch window (defined to be`pageSize + (2 * prefetchDistance)`) of the most recent load.

If not set, defaults to[PagedList.Config.Companion.MAX_SIZE_UNBOUNDED](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Companion#MAX_SIZE_UNBOUNDED()), which disables page dropping.  

|                                                                                         Parameters                                                                                          |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `maxSize: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 2) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Maximum number of items to keep in memory, or[PagedList.Config.Companion.MAX_SIZE_UNBOUNDED](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Companion#MAX_SIZE_UNBOUNDED())to disable page dropping. |

|                                                       Returns                                                       |
|---------------------------------------------------------------------------------------------------------------------|------|
| [PagedList.Config.Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder) | this |

|                                                               See also                                                               |
|--------------------------------------------------------------------------------------------------------------------------------------|---|
| [MAX_SIZE_UNBOUNDED](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Companion#MAX_SIZE_UNBOUNDED()) |   |
| [maxSize](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config#maxSize())                                 |   |

### setPageSize

android  
Added in[2.0.0](https://developer.android.com/jetpack/androidx/releases/paging#2.0.0)  
Deprecated in[3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)  

```
fun [setPageSize](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setPageSize(kotlin.Int))(pageSize: @IntRange(from = 1) Int): PagedList.Config.Builder
```
| **This function is deprecated.**   
| PagedList is deprecated and has been replaced by PagingData

Defines the number of items loaded at once from the[PagingSource](https://developer.android.com/reference/kotlin/androidx/paging/PagingSource).

Should be several times the number of visible items onscreen.

Configuring your page size depends on how your data is being loaded and used. Smaller page sizes improve memory usage, latency, and avoid GC churn. Larger pages generally improve loading throughput, to a point (avoid loading more than 2MB from SQLite at once, since it incurs extra cost).

If you're loading data for very large, social-media style cards that take up most of a screen, and your database isn't a bottleneck, 10-20 may make sense. If you're displaying dozens of items in a tiled grid, which can present items during a scroll much more quickly, consider closer to 100.  

|                                                                                          Parameters                                                                                          |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| `pageSize: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Number of items loaded at once from the[PagingSource](https://developer.android.com/reference/kotlin/androidx/paging/PagingSource). |

|                                                       Returns                                                       |
|---------------------------------------------------------------------------------------------------------------------|------|
| [PagedList.Config.Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder) | this |

|                                                             Throws                                                             |
|--------------------------------------------------------------------------------------------------------------------------------|-----------------------|
| [kotlin.IllegalArgumentException](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html) | if pageSize is \<`1`. |

### setPrefetchDistance

android  
Added in[2.0.0](https://developer.android.com/jetpack/androidx/releases/paging#2.0.0)  
Deprecated in[3.0.0](https://developer.android.com/jetpack/androidx/releases/paging#3.0.0)  

```
fun [setPrefetchDistance](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder#setPrefetchDistance(kotlin.Int))(prefetchDistance: @IntRange(from = 0) Int): PagedList.Config.Builder
```
| **This function is deprecated.**   
| PagedList is deprecated and has been replaced by PagingData

Defines how far from the edge of loaded content an access must be to trigger further loading.

Should be several times the number of visible items onscreen.

If not set, defaults to page size.

A value of 0 indicates that no list items will be loaded until they are specifically requested. This is generally not recommended, so that users don't observe a placeholder item (with placeholders) or end of list (without) while scrolling.  

|                                                                                              Parameters                                                                                              |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| `prefetchDistance: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Distance the[PagedList](https://developer.android.com/reference/kotlin/androidx/paging/PagedList)should prefetch. |

|                                                       Returns                                                       |
|---------------------------------------------------------------------------------------------------------------------|------|
| [PagedList.Config.Builder](https://developer.android.com/reference/kotlin/androidx/paging/PagedList.Config.Builder) | this |