Using Realm-Android-Adapters, you can implement RecyclerView with Realm integrated.

First of all, you have to include Realm and Realm-Android-Adapters into Android project.

// app/build.gradle
apply plugin: 'realm-android'

dependencies {
// Realm Android Adapters
implementation 'io.realm:android-adapters:3.1.0'
}
// project/build.gradle
buildscript {
dependencies {
classpath "io.realm:realm-gradle-plugin:5.9.1"
}
}

Secondly, create ViewAdapter class extending RealmRecyclerViewAdapter . In this example, RealmModel inherits RealmObject .

class ViewAdapter(val list: OrderedRealmCollection<RealmModel>, autoUpdate: Boolean): RealmRecyclerViewAdapter<RealmModel, ViewHolder>(list, autoUpdate) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_realm_model, parent, false)
return ViewHolder(view)
}

override fun getItemCount(): Int = list.size

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.textView.text = list[position].text
}
}

Lastly, set the adapter to RecyclerView . With autoUpdate true, when Realm update then RecyclerView automatically updated.

recyclerView.apply {
adapter = ViewAdapter(
Realm.getDefaultInstance().where(RealmModel::class.java).findAll(),
true
)
}