The Paging Architecture Component makes it easier for your app to gradually load information as needed from a data source, without overloading the device or waiting too long for a big database query.
Overview:-
Many apps work with large sets of data, but only need to load and display a small portion of that data at any time. An app might have thousands of items that it could potentially display, but it might only need access to a few dozen of them at once. If the data is stored or synchronized with a remote database, this can also slow the app and waste the user's data plan
While existing Android APIs allowed for paging in content, they came with significant constraints and drawbacks:
- CursorAdapter makes it easier to map database query results to ListView items.
- AsyncListUtil allows for paging position-based data into a RecyclerView but doesn't allow for non-positional paging, and it forces nulls-as-placeholders in a countable data set.
Classes:-
The Paging Library provides the following classes, as well as additional supporting classes:
- DataSource: Use this class to define a data source you need to pull paged data from.
- PagedList: This class loads data from a DataSource. You can configure how much data is loaded at a time, and how much data should be prefetched, minimizing the amount of time your users have to wait for data to be loaded.
- PagedListAdapter: This class is an implementation of RecyclerView.Adapter that presents data from a PagedList.
- LivePagedListProvider: This class generates a LiveData from the DataSource you provide.