Check Mobile App
Read now
Start a Project

Android Room Persistence Library


The Room persistence library provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite.

Add the Google Maven repository:

Add this dependencies in module build.gradle:

Now let’s begin with Room persistence library create a class User. User Class is annotated with @Entity and name of the table. To make field primary key, you need to annotate a field with @PrimaryKey and property autoGenerate which assign automatic IDs.

Create a data access object using an interface. This class is annotated with @Dao annotation. Room will generate an implementation of defined methods. There are four annotations @Query@Insert.

Create a database holder called AppDatabase extends RoomDatabase, we will define list of entities and database version. Class is annotated with @Database annotation. It is good practice to use singleton approach for the database, so you need to create an static method which will return instance of AppDatabase.

For insert data in database and get User list from the data:


. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.


Very good company, we did get app extension for Magento 2 website. The support was very good they help us through the process. Webkul team is very supportive, I would recommend them.

Yasser Mohamed

Yasser Mohamed

Talk to Sales


Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home