added in version 1.1.0
belongs to Maven artifact android.arch.persistence.room:runtime:1.1.0-beta2

InvalidationTracker

public class InvalidationTracker
extends Object

java.lang.Object
   ↳ android.arch.persistence.room.InvalidationTracker


InvalidationTracker keeps a list of tables modified by queries and notifies its callbacks about these tables.

Summary

Nested classes

class InvalidationTracker.Observer

An observer that can listen for changes in the database. 

Public methods

void addObserver(InvalidationTracker.Observer observer)

Adds the given observer to the observers list and it will be notified if any table it observes changes.

void refreshVersionsAsync()

Enqueues a task to refresh the list of updated tables.

void removeObserver(InvalidationTracker.Observer observer)

Removes the observer from the observers list.

Inherited methods

Object clone()
boolean equals(Object arg0)
void finalize()
final Class<?> getClass()
int hashCode()
final void notify()
final void notifyAll()
String toString()
final void wait(long arg0, int arg1)
final void wait(long arg0)
final void wait()

Public methods

addObserver

added in version 1.1.0
void addObserver (InvalidationTracker.Observer observer)

Adds the given observer to the observers list and it will be notified if any table it observes changes.

Database changes are pulled on another thread so in some race conditions, the observer might be invoked for changes that were done before it is added.

If the observer already exists, this is a no-op call.

If one of the tables in the Observer does not exist in the database, this method throws an IllegalArgumentException.

Parameters
observer InvalidationTracker.Observer: The observer which listens the database for changes.

refreshVersionsAsync

added in version 1.1.0
void refreshVersionsAsync ()

Enqueues a task to refresh the list of updated tables.

This method is automatically called when endTransaction() is called but if you have another connection to the database or directly use SupportSQLiteDatabase, you may need to call this manually.

removeObserver

added in version 1.1.0
void removeObserver (InvalidationTracker.Observer observer)

Removes the observer from the observers list.

Parameters
observer InvalidationTracker.Observer: The observer to remove.

Discover the latest app development tools, platform updates, training, and documentation for developers across every Android device.

Updated Apr 11, 2024

Android Studio provides app builders with an integrated development environment (IDE) optimized for Android apps. Download Android Studio today.

Updated Dec 23, 2024

Discover the latest app development tools, platform updates, training, and documentation for developers across every Android device.

Updated Dec 18, 2024