Room Database

What is Room Database?

Its an abstraction layer over Sqlite which provide full access over database

Object Relation Mapping(ORM) library that mean it map our database object to our java object.

Component of Room Database


2.DAO(Data Access Object)


1.Entity → create a table within a database if we annote @Entity to the top of the class it will create a table within database.

@PrimarKey is used to define its unique ,the sqlite will create a unique id for the mentioned column if we decalre autogenerate = true inside the PrimaryKey

@ColumnInfo(name = “columnname”) will give information about the particullar column we can mention the column name inside ColumnInfo

2.DAO(Data Access Object)

Where we access database function such as insert,delete and update.

we will create an interface with @DAO annotation for accessing database

DataBase where we define our entities,tablename and DAO and we make this class as abstract which extends RoomDatabase and we use singleton pattern for creating instance with static variable so it can accessed in main class without creating object just by class name.

the .fallbackToDestructiveMigration() will destroy and create the table inside database

Calling from main class

Knowledge is everything.Check out my app at

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

My Personal goals and expectations at HNG 8.0 Internship.

Recommendation system with azure

Amazon Interview Experience

Continuously delivering Akamai property changes

Internationalizing and Localizing Your App, Part 3: Technical Challenges

SonarQube — Static Code Analysis

Udemy: Course Purchase Guide

Delve for debugging live Go application

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pandiyan Mani

Pandiyan Mani

Knowledge is everything.Check out my app at

More from Medium

How to set JAVA_HOME variable in windows?

Reducing your request payload size through compression

How to switch from one activity to another in Android Studio

Android Tutorial: UI Components