SQlite Database VS Room persistence library [closed] SQlite Database VS Room persistence library [closed] android android

SQlite Database VS Room persistence library [closed]


Room is an ORM, Object Relational Mapping library. In other words, Room will map our database objects to Java objects.Room provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite.

Difference between SQLite and Room persistence library:-

  • In case of SQLite, There is no compile time verification of raw SQLite queries. But in Room there is SQL validation at compile time.
  • As your schema changes, you need to update the affected SQL queries manually. Room solves this problem.
  • You need to use lots of boilerplate code to convert between SQL queries and Java data objects. But, Room maps our database objects to Java Object without boilerplate code.
  • Room is built to work with LiveData and RxJava for data observation, while SQLite does not.

Room annotations and main components:

  1. @Entity — Define our database tables
  2. @DAO — Provide an API for reading and writing data
  3. @Database — Represent a database holder

Here is the link to the medium article which explains in detail the usage and benefits of Room persistence library.I hope this helps.

Edit 1: You can refer to Google developer docs, which clearly explains how to save data in a local database using room. Link to Google Developer Docs