Paging (Arch. Comp.)
The Android Paging Library helps you load and display small data chunks at a time. Learn to use ObjectBox database with the Paging library from Android Architecture Components.
Last updated
Was this helpful?
The Android Paging Library helps you load and display small data chunks at a time. Learn to use ObjectBox database with the Paging library from Android Architecture Components.
Last updated
Was this helpful?
ObjectBox supports integration with the that is part of Google's . To that end, the (objectbox-android
) provides the ObjectBoxDataSource
class. It is an implementation of the Paging library's .
Within your ViewModel
, similar to , you first . But then, you construct an ObjectBoxDataSource
factory with it instead. This factory is then passed to a LivePagedListBuilder
to build the actual LiveData
.
Here is an example of a ViewModel
class doing just that:
Note that the LiveData
holds your entity class, here Note
, wrapped inside a PagedList
. You observe the LiveData
as usual in your activity or fragment, then submit the PagedList
on changes to your PagedListAdapter
of the Paging library.
We will not duplicate how this works here, see the for details about this.
Have a look at the .
Check out .
Learn how to .