66[ ObjectBox] ( https://objectbox.io/ ) is a superfast object-oriented database with strong relation support.
77ObjectBox is embedded into your Android, Linux, macOS, or Windows app.
88
9- ** Latest version: [ 2.9.1 (2021/03/15 )] ( https://docs.objectbox.io/#objectbox-changelog ) **
9+ ** Latest version: [ 3.0.0 (2021/10/19 )] ( https://docs.objectbox.io/#objectbox-changelog ) **
1010
1111Demo code using ObjectBox:
1212
13+ ``` kotlin
14+ // Kotlin
15+ val playlist = Playlist (" My Favorites" )
16+ playlist.songs.add(Song (" Lalala" ))
17+ playlist.songs.add(Song (" Lololo" ))
18+ box.put(playlist)
19+ ```
20+
1321``` java
22+ // Java
1423Playlist playlist = new Playlist (" My Favorites" );
1524playlist. songs. add(new Song (" Lalala" ));
1625playlist. songs. add(new Song (" Lololo" ));
@@ -29,27 +38,40 @@ Besides JVM based languages like Java and Kotlin, ObjectBox also offers:
2938
3039Gradle setup
3140------------
32- Add this to your root build.gradle (project level) :
41+ For Android projects, add the ObjectBox Gradle plugin to your root ` build.gradle ` :
3342
3443``` groovy
3544buildscript {
36- ext.objectboxVersion = '2.9.1'
45+ ext.objectboxVersion = "3.0.0"
46+ repositories {
47+ mavenCentral()
48+ }
3749 dependencies {
38- classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
50+ classpath( "io.objectbox:objectbox-gradle-plugin:$objectboxVersion")
3951 }
4052}
4153```
4254
43- And this to our app's build.gradle (module level) :
55+ And in your app's ` build.gradle ` apply the plugin :
4456
4557``` groovy
46- apply plugin: 'io.objectbox' // after applying Android plugin
58+ // Using plugins syntax:
59+ plugins {
60+ id("io.objectbox") // Add after other plugins.
61+ }
62+
63+ // Or using the old apply syntax:
64+ apply plugin: "io.objectbox" // Add after other plugins.
4765```
4866
4967First steps
5068-----------
51- Create data object class ` @Entity ` , for example "Playlist".
52- ``` java
69+ Create a data object class ` @Entity ` , for example "Playlist".
70+ ```
71+ // Kotlin
72+ @Entity data class Playlist( ... )
73+
74+ // Java
5375@Entity public class Playlist { ... }
5476```
5577Now build the project to let ObjectBox generate the class ` MyObjectBox ` for you.
0 commit comments