Room là lớp trừu tượng type-safe trên SQLite, tự động sinh code lúc compile, ngăn SQL injection và lỗi runtime.
- Bạn định nghĩa entity (data class), DAO (database access object với query), và Database class.
- Room hỗ trợ LiveData/Flow để quan sát thay đổi database.
- An toàn và dễ dùng hơn SQLite thô rất nhiều, và tích hợp tốt với coroutine và Compose.
Room is a type-safe abstraction over SQLite that auto-generates code at compile time, preventing SQL injection and runtime errors.
- You define entities (data classes), DAOs (database access objects with queries), and a Database class.
- Room provides LiveData/Flow support for observing database changes and is much safer and easier than raw SQLite queries.