跳至主要内容

博文

目前显示的是 九月, 2019的博文

How to use Realm database in Kotlin

Hot to use Realm in android project. Befor you use realm we should be read documentation https://realm.io/docs/java/latest#getting-started Then we got the way how to install. Install Realm as a Gradle plugin. Setp 1:   change build.gradle in project level buildscript { repositories { jcenter() } dependencies { classpath "io.realm:realm-gradle-plugin:5.14.0" } } Step 2:   Apply the realm-android plugin to the top of the application level build.gradle file. Create reaml map Object There has two way for mapping Object Make   Object   extends   ReamlObject Or make   Object   implement   ReamlModel Declear reaml mapping objects Realm not support   data class   yet. So we can't use it now. And object will make it open, because Realm object will generate subclass after   aapt   or   kapt . // 1. open class User : RealmObject() { var id: String = UUID . random UUID() . to String() var name: String = "