Skip to content

How to Fix Android RecyclerView Not Updating

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about How to Fix Android RecyclerView Not Updating. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

You update the data list but the RecyclerView stays unchanged:

dataList.add(newItem)
adapter.notifyDataSetChanged() // nothing happens

Or items render with stale data, duplicate entries, or blank views.

The Adapter is not notified of changes correctly, or the LayoutManager does not remeasure after updates.

Quick Fix

Step 1: Use notifyItemInserted instead of notifyDataSetChanged

dataList.add(newItem)
adapter.notifyItemInserted(dataList.size - 1)

notifyDataSetChanged is inefficient and can miss animations. Use targeted notifications:

Change Method
Item added notifyItemInserted(index)
Item removed notifyItemRemoved(index)
Item changed notifyItemChanged(index)
Multiple changes notifyItemRangeInserted/Removed/Changed

Step 2: Apply all changes before notifying

fun updateData(newList: List<Item>) {
    dataList.clear()
    dataList.addAll(newList)
    adapter.notifyDataSetChanged()
}

Clearing and notifying outside the Adapter's internal list causes inconsistencies.

Step 3: Use ListAdapter with DiffUtil

class MyAdapter : ListAdapter<Item, MyViewHolder>(DiffCallback()) {

    override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
        holder.bind(getItem(position))
    }
}

class DiffCallback : DiffUtil.ItemCallback<Item>() {
    override fun areItemsTheSame(old: Item, new: Item) = old.id == new.id
    override fun areContentsTheSame(old: Item, new: Item) = old == new
}

Submit new list with <a href="/design-patterns/adapter/">Adapter</a>.submitList(newList) instead of calling notify methods manually.

Step 4: Check the LayoutManager

// Verify the LayoutManager is set
recyclerView.layoutManager = LinearLayoutManager(this)

Without a LayoutManager, the RecyclerView does not display any items. Verify this is set before the Adapter.

Step 5: Check data source reference

// Wrong - creates a new list, adapter still references the old one
dataList = fetchNewData()
adapter.notifyDataSetChanged()

// Right - mutate the existing list reference
dataList.clear()
dataList.addAll(fetchNewData())
adapter.notifyDataSetChanged()

Step 6: Call notifyDataSetChanged on main thread

runOnUiThread {
    adapter.notifyDataSetChanged()
}

RecyclerView modifications must happen on the main thread. Background thread notifications are silently ignored.

Prevention

  • Use ListAdapter with DiffUtil for automatic, animated updates.
  • Always call notify methods after actual data mutations.
  • Keep a single source of truth for the Adapter's data list.

Common Mistakes with recyclerview not updating

  1. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  2. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  3. Using return to exit a function early instead of wrapping a pure value in the monad

These mistakes appear frequently in real-world Android code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why does notifyDataSetChanged not refresh the RecyclerView?

The Adapter's internal list reference differs from the one being modified. Mutating a separate variable does not update the Adapter. Always modify the list held by the Adapter.

What is the advantage of DiffUtil over notifyDataSetChanged?

DiffUtil calculates the minimum set of operations (insert, remove, move, change) between old and new lists, enabling item animations and better performance.

Can RecyclerView updates happen on a background thread?

No. All Adapter notify calls must run on the main thread. Use submitList with ListAdapter, which internally posts to the main thread.

DodaTech Tool Reference

Doda Browser's UI Profiler captures RecyclerView rendering performance in real time, helping identify jank from incorrect notification patterns.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro