Search code examples
androidandroid-sqliteandroid-roomandroid-jetpackandroid-paging

Is it possible to use Paging (As part of android jetpack) without using Room DB?


Right now I'm working on an Android project which contains a RecyclerView with a large amount of data. For improving the app's performance I wish to implement the Paging component introduced in Android Jetpack. Since the project is pretty old, it is using SQliteOpenHelper for SQLite implementation instead of Room DB. In all of the paging examples found in related to paging using Room DB to fetch 'PagedList', so is it possible to use paging without room?

Thanks in advance.


Solution

  • It is possible, find use of Pagination library with remote api calls. Just in your case you won't make call to remote api, but to database. After you fetch data from db, you will populate datasource and voila, you have pagination. Concept in Pagination with db and remote api is the same, Room only wrapped it so you can skip 2 steps.

    So yes, it is possible, you just need that two extra steps to achieve it.

    Creating a custom data source for paging: