Reference

Room Persistence Library

Room is an Android Jetpack persistence library that provides a typed abstraction layer over SQLite. It maps annotated entity classes to tables, validates SQL queries at compile time, and exposes results as Flow or LiveData for reactive UIs.

Android developmentAndroid

Room Persistence Library

Also known as: room android, room orm

Room is an Android Jetpack persistence library that provides a typed abstraction layer over SQLite. It maps annotated entity classes to tables, validates SQL queries at compile time, and exposes results as Flow or LiveData for reactive UIs.

  • Part of Android Jetpack; sits on top of SQLite.
  • Validates SQL queries at compile time via its annotation processor.
  • Returns reactive results as Flow, LiveData, or RxJava streams.

What Room provides

Room is the recommended way to use a local SQLite database on Android. It has three core parts: an `@Entity`-annotated class that defines a table, a `@Dao` interface that declares queries, and an `@Database` class that ties them together.

Room's annotation processor verifies SQL at compile time, so a typo in a query fails the build rather than crashing at runtime. It maps rows to objects, handles migrations through `Migration` objects (or schema-validated auto-migrations), and returns observable types like Flow, LiveData, or RxJava streams.

Because it is a thin layer over SQLite, the same on-disk file can be inspected, indexed, and compacted with VACUUM like any other SQLite database.

How a cleaner uses it

A storage cleaner stores its scan index in a Room database: one row per file path with size, last-modified time, and a content fingerprint. Querying that index is far faster than re-walking the filesystem on every launch.

Room also holds the dedupe hashes (such as a perceptual hash per image) used to group duplicate photos. As the index churns over many scans the database file can bloat, so the cleaner periodically runs SQLite VACUUM to reclaim that space.

Related terms

Keep reading the reference.

Act on it

Guides and tools for this topic.