Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Java for Android
  • Android Studio
  • Android Kotlin
  • Kotlin
  • Flutter
  • Dart
  • Android Project
  • Android Interview
Open In App
Next Article:
Getting Started with Paging Library v3 in Android
Next article icon

Getting Started with Paging Library v3 in Android

Last Updated : 04 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

When building Android apps that show long lists of information—like news articles, product listings, or social media posts—developers often use a RecyclerView. This component helps display a list of items efficiently. But if the list is very large, loading all the data at once can slow down the app, waste internet data, and use too much memory. Imagine an app that loads hundreds or thousands of items from the internet. Even though only a few items are visible on the screen at any moment, the app may try to download and store everything right away. This is inefficient and leads to Slower performance, More data usage, Higher memory consumption and Poor user experience. The solution to this problem was Pagination.

What is Pagination?

Pagination means breaking down the data into smaller parts, or "pages," and loading them only when needed. For example, you load the first 20 items, and when the user scrolls to the bottom, you load the next 20. This is how apps like Instagram or Twitter show more content as you scroll. To help developers implement pagination easily and efficiently, Google introduced the Paging 3 library as part of Android Jetpack. It was released around the time of Android 11 Beta.

How Paging Works?

The following steps are how the Paging library works:

  1. The app shows a small portion of data (for example, 20 items).
  2. As the user scrolls down, the app detects that the user is near the bottom.
  3. The app automatically fetches the next "page" of data (another 20 items).
  4. This continues as the user keeps scrolling, giving the experience of an "infinite list."


Pagination in Android

Advantages of using Paging Library

The Paging 3.0 version is very unique in comparison to the previous versions of the Android Paging library. Following are the new features and their advantages:

  • It supports error handling with built-in refresh and retry features.
  • It works perfectly with Kotlin Coroutines, Flow, LiveData, and RxJava.
  • It allows easy addition of loading headers, footers, and list separators.
  • It caches data in memory to improve performance and reduce resource usage.
  • It automatically manages page keys for next and previous data loads.
  • It prevents duplicate API calls to save bandwidth and system resources.
  • It improves the repository layer with easy cancellation and cleaner APIs.

Dependency for Paging Library

Apply the Paging 3.0 library in a project by adding its implementation in the Gradle Scripts >build.gradle.kts (Module :app) file to import the Paging components.

dependencies {
...
implementation("androidx.paging:paging-runtime:3.3.6")
}

Check the latest version of paging library here.

The Architecture of Paging Library

The Paging library is designed to follow the recommended Android architecture, which separates the app into different layers. This helps keep the code clean, organized, and easier to maintain. The Paging library mainly works across three layers of an app:

  1. Repository layer
  2. ViewModel layer
  3. UI layer
The Architecture of Paging Library
  1. Repository Layer - This layer handles where and how the data is loaded. It uses two main components:
    • PagingSource: Defines the source of data and fetches it, either from a local database or from the internet (API).
    • RemoteMediator: Manages paging when you're combining data from multiple sources, like syncing a remote API with a local database.
  2. ViewModel Layer - The ViewModel creates and manages a stream of paginated data using the Pager class. This produces PagingData, which is then exposed to the UI through reactive streams like Kotlin Flow or LiveData.
  3. UI Layer - This is where the paginated data is displayed to the user. It uses PagingDataAdapter, which is a special RecyclerView adapter that knows how to handle PagingData and show items as they load.

Next Article
Getting Started with Paging Library v3 in Android

P

pratthamarora
Improve
Article Tags :
  • Technical Scripter
  • Kotlin
  • Android
  • Technical Scripter 2020
  • Android-Misc

Similar Reads

    How to Implement Paging Library in Android with Example?
    As the number of users of a particular mobile application grows, so does the amount of data associated with that application. For example, as the number of Instagram app users increased, so did the number of daily feeds on the app. In general, if we want to display data from a remote server in our A
    11 min read
    Cube in Scaling Animation with ViewPager in Android
    The Android ViewPager has become a very interesting concept among Android apps. It enables users to switch smoothly between fragments which have a common UI and it’s the best way to make your app extraordinary from others. ViewPagers provide visual continuity. They basically keep track of which page
    4 min read
    SearchView in Android with ListView
    SearchView is a widget provided by the Android framework that allows users to search for specific data within an application. It is commonly used in apps that have large amounts of data or content that can be searched, such as contacts, music, or emails. The SearchView widget consists of an input fi
    2 min read
    Tinder Swipe View with Example in Android
    Tinder Swipe View is one of the most used UI components in many Android apps. This feature provides us to easily represent the data in a huge list form. In this article, we will take a look at implementing this Swipe View feature in our Android App. What we are going to build in this Article? We wil
    8 min read
    Android ListView in Java with Example
    A ListView in Android is a type of AdapterView that displays a vertically scrollable list of items, with each item positioned one below the other. Using an adapter, items are inserted into the list from an array or database efficiently. For displaying the items in the list method setAdaptor() is use
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences