This article is written for someone who just wants to give it a try anyway.
If youre interested in details, please read the official docs.
The application that youre going to make from now, inserts 1 user with 2 breads every time you start the app. :)

1. Add this line to the project level build.gradle.

classpath 'io.realm:realm-gradle-plugin:3.1.4'

2. Add this line to the top of the application level build.gradle.

apply plugin: 'realm-android'

3. Refresh gradle dependencies.

4. Configure a Realm in

5. Add MyApplication to application tag in the apps AndroidManifest.xml.


6. Create a User class.
You can mark a field as a primary key with @PrimaryKey.
Other annotation types summary is HERE.

7. Create a Bread class.

8. Write insert function in
As I mentioned before, this app inserts 1 user and 2 breads into Realm DB when onCreate() is called.
There is an auto-incrementing ID helper but its not recommended when you:

1) Create Realm Objects in multiple processes. 2) Want to share the Realm between multiple devices at some point in the future.

Here is an example of auto-Increment ID for creating objects across processes.

Example of delete function.

User u = mRealm.where(User.class).equalTo("id", id).findFirst();

9. Copy database to somewhere accessible.
Realm provides a Mac app to edit and read your database.
Currently, this app doesnt support accessing database directly.
You have to copy it from emulator or device to somewhere accessible.

$ adb shell "run-as chmod 666 /data/data/”

$ adb exec-out run-as cat files/default.realm > default.realm

$ adb shell "run-as chmod 600 /data/data/"

10. View your database in Realm Browser.
Choose Open Realm File and you can view it.

User table

Bread table

Youre done!
Now youre able to explore Realm world by yourself. Enjoy! :)