In today's tutorial, we are going to be learning how to copy our realm database objects and then save it in Room Database.
We develop an Android application that displays a list of Objects on the MainActivity layout file and when the user clicks a button, the objects are copied and stored in the Room Database and then displayed on the other textview.
The user is expected to click on the Database copy button to initialize the copying of the realm objects to the Room Database and also displaying the copy objects.
The source code of this tutorial can be found here
Time Frame
Application Sample - 00:00 - 00:47
Dependencies Used - 01:10 - 02:46
Setting up Room Database - 02:50 - 09:40
Setting up our MainActivity Layout file - 09:44 - 11:49
Linking Everything together - 11:52 - 23:47
Overview
Application Sample: This part of this tutorial shows the sample application that we intend to build.
Dependencies Used: In this part the used dependencies in the tutorial are being shown here, dependencies such as - butterknife (Used for view injection) , Lombok library (Used for reduction of Boiler plate code), Room(Used for creating and accessing sqlite database), Realm(Used for storing realm objects).
Setting up Room Database - This part of the tutorial we setup the three components of the Room Database (Entity, Database Access Object (DAO), Database object).
Setting up our MainActivity layout file (activity_main.xml) : This part of the tutroial, we set up the main activity layout file where we add Two TextVIews and a Button to our activitymain.xml file inwhich the two textviews will be used to display the details of the Realm and Room Database contents.
Linking Everything Together - In this part, we link all the earlier created components of the Application, and then we finally do the copying of the realm database content to the room database.