create account

How to Copy Realm Objects to Room Database using Android Studio by edetebenezer

View this thread on: hive.blogpeakd.comecency.com
· @edetebenezer · (edited)
$10.51
How to Copy Realm Objects to Room Database using Android Studio
![realmDark.jpg](https://steemitimages.com/DQmSaAL6Dn3yz6wYscgL4mUL3jGUZ4Zv1J1KvChgz1LxogX/realmDark.jpg)

### Repository
https://github.com/realm/realm-java

#### What Will I Learn?

- You will learn how to copy Realm Database Content to Room Database.
- You will learn how to use Realm Queries.
- How to use butterknife to inject views.
- How to use Lombok library to reduce boilerplate codes.

#### Requirements

#### System Requirements
- An Integrated Development Environment(IDE) for building Android Application(e.g Android Studio, IntelliJ)
- Android Device/Virtual Device.

#### Required Knowledge
- Little Experience in working with Realm Java.
- Java Programming Experience.
- Little or no Experience working with Room
- Of course, willingness to learn

#### Resources
- Realm Website. https://realm.io/
- Realm  Github. - https://github.com/realm
- Realm License - Apache License
- Lombok Website - https://projectlombok.org
- Room Official Documentation - https://developer.android.com/topic/libraries/architecture/room

#### Difficulty

- Intermediate

#### Tutorial Content
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]("https://github.com/generalkolo/Realm-Examples/tree/master/RealmToRoom")

#### 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.


#### Video Tutorial
https://youtu.be/2Hjtjhu-QUY

### Proof of Work
https://github.com/generalkolo/Realm-Examples/tree/master/RealmToRoom
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 70 others
properties (23)
authoredetebenezer
permlinkhow-to-copy-realm-objects-to-room-database-using-android-studio
categoryutopian-io
json_metadata{"tags":["utopian-io","video-tutorials","steemstem","steemiteducation","android"],"image":["https://steemitimages.com/DQmSaAL6Dn3yz6wYscgL4mUL3jGUZ4Zv1J1KvChgz1LxogX/realmDark.jpg","https://img.youtube.com/vi/2Hjtjhu-QUY/0.jpg"],"links":["https://github.com/realm/realm-java","https://realm.io/","https://github.com/realm","https://projectlombok.org","https://developer.android.com/topic/libraries/architecture/room","\"https://github.com/generalkolo/Realm-Examples/tree/master/RealmToRoom\"","https://youtu.be/2Hjtjhu-QUY","https://github.com/generalkolo/Realm-Examples/tree/master/RealmToRoom"],"app":"steemit/0.1","format":"markdown"}
created2018-08-02 15:42:51
last_update2018-08-05 07:46:51
depth0
children5
last_payout2018-08-09 15:42:51
cashout_time1969-12-31 23:59:59
total_payout_value8.146 HBD
curator_payout_value2.360 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,202
author_reputation11,731,914,898,386
root_title"How to Copy Realm Objects to Room Database using Android Studio"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,891,241
net_rshares6,263,943,840,547
author_curate_reward""
vote details (134)
@postoffice ·
Chic  article. I learned a lot of interesting and cognitive. I'm screwed up with you, I'll be glad to reciprocal subscription))
πŸ‘  
properties (23)
authorpostoffice
permlinkre-edetebenezer-how-to-copy-realm-objects-to-room-database-using-android-studio-20180802t154430224z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-08-02 15:44:27
last_update2018-08-02 15:44:27
depth1
children0
last_payout2018-08-09 15:44:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length127
author_reputation-1,355,889,345,456
root_title"How to Copy Realm Objects to Room Database using Android Studio"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id66,891,373
net_rshares3,512,493,864
author_curate_reward""
vote details (1)
@utopian-io ·
Hey @edetebenezer
**Thanks for contributing on Utopian**.
We’re already looking forward to your next contribution!

**Want to chat? Join us on Discord https://discord.gg/h52nFrV.**

<a href='https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-how-to-copy-realm-objects-to-room-database-using-android-studio-20180806t231009z
categoryutopian-io
json_metadata"{"app": "beem/0.19.42"}"
created2018-08-06 23:10:09
last_update2018-08-06 23:10:09
depth1
children0
last_payout2018-08-13 23:10:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length304
author_reputation152,955,367,999,756
root_title"How to Copy Realm Objects to Room Database using Android Studio"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id67,347,682
net_rshares0
@yokunjon · (edited)
$0.03
I thank you for your contribution. Here are my thoughts;

* There was a lot of background noises including keystrokes and some of your sentences were unclear / incomprehensible. To solve it, you can change your microphone settings and practice before talking.

* What you've shown in the video tutorial is rather practical than theoretical. Every person with little programming skill and database knowledge can find own way in these situations. A tutorial should encourage users to find their way, shouldn't show or force them the way.

----
Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, [click here](https://review.utopian.io/result/9/333333243).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  ,
properties (23)
authoryokunjon
permlinkre-edetebenezer-how-to-copy-realm-objects-to-room-database-using-android-studio-20180806t211045011z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/9/333333243","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-08-06 21:10:27
last_update2018-08-07 10:23:45
depth1
children2
last_payout2018-08-13 21:10:27
cashout_time1969-12-31 23:59:59
total_payout_value0.021 HBD
curator_payout_value0.004 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,033
author_reputation19,266,807,595,513
root_title"How to Copy Realm Objects to Room Database using Android Studio"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id67,339,318
net_rshares17,965,862,231
author_curate_reward""
vote details (2)
@edetebenezer ·
Well thanks @yokunjon for moderating but, 
> A tutorial should encourage users to find their way, shouldn't show or force them the way.

I really don't understand what you meant by that.
The tutorial is to show the users how to accomplish a certain task with best Android practices.
πŸ‘  
properties (23)
authoredetebenezer
permlinkre-yokunjon-re-edetebenezer-how-to-copy-realm-objects-to-room-database-using-android-studio-20180806t214755295z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["yokunjon"],"app":"steemit/0.1"}
created2018-08-06 21:33:27
last_update2018-08-06 21:33:27
depth2
children1
last_payout2018-08-13 21:33:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length282
author_reputation11,731,914,898,386
root_title"How to Copy Realm Objects to Room Database using Android Studio"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id67,340,875
net_rshares5,327,148,617
author_curate_reward""
vote details (1)
@yokunjon ·
I thank you for the feedback. Briefly, what you've done is showing how you solve the problem. Actually, it's a basic engineering problem. In these situations, the real learning happens when the user solves it by himself. So, the content of your tutorial isn't a good example as a tutorial. You've already shown them how to create Realms databases, so let them find their own way and migrate their databases to another one when needed. Because, if you were to show the same thing for each database, it would be lots of content which repeats itself.

A real world example would be teaching how to step each step rather than generally walking.

If you need more detailed/further explanation, that is not problem, don't hesitate to ask. :)
πŸ‘  ,
properties (23)
authoryokunjon
permlinkre-edetebenezer-re-yokunjon-re-edetebenezer-how-to-copy-realm-objects-to-room-database-using-android-studio-20180806t223030909z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-08-06 22:30:12
last_update2018-08-06 22:30:12
depth3
children0
last_payout2018-08-13 22:30:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length735
author_reputation19,266,807,595,513
root_title"How to Copy Realm Objects to Room Database using Android Studio"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id67,344,834
net_rshares730,203,741
author_curate_reward""
vote details (2)