@@ -7,46 +7,56 @@ ObjectBox is a superfast object-oriented database with strong relation support.
7
7
8
8
Demo code using ObjectBox:
9
9
10
- Playlist playlist = new Playlist("My Favorties");
11
- playlist.songs.add(new Song("Lalala"));
12
- playlist.songs.add(new Song("Lololo"));
13
- box.put(playlist);
10
+ ``` java
11
+ Playlist playlist = new Playlist (" My Favorties" );
12
+ playlist. songs. add(new Song (" Lalala" ));
13
+ playlist. songs. add(new Song (" Lololo" ));
14
+ box. put(playlist);
15
+ ```
14
16
15
17
Gradle setup
16
18
------------
17
19
Add this to your root build.gradle (project level):
18
20
19
- buildscript {
20
- ext.objectboxVersion = '1.3.4'
21
- repositories {
22
- maven { url "http://objectbox.net/beta-repo/" }
23
- }
24
- dependencies {
25
- classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
26
- }
27
-
21
+ ``` groovy
22
+ buildscript {
23
+ ext.objectboxVersion = '1.3.4'
24
+ repositories {
25
+ maven { url "http://objectbox.net/beta-repo/" }
28
26
}
29
-
30
- allprojects {
31
- repositories {
32
- maven { url "http://objectbox.net/beta-repo/" }
33
- }
27
+ dependencies {
28
+ classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
34
29
}
35
30
31
+ }
32
+
33
+ allprojects {
34
+ repositories {
35
+ maven { url "http://objectbox.net/beta-repo/" }
36
+ }
37
+ }
38
+ ```
39
+
36
40
And this to our app's build.gradle (module level):
37
41
38
- apply plugin: 'io.objectbox' // after applying Android plugin
42
+ ``` groovy
43
+ apply plugin: 'io.objectbox' // after applying Android plugin
44
+ ```
39
45
40
46
First steps
41
47
-----------
42
48
Prepare the BoxStore object once for your app, e.g. in ` onCreate ` in your Application class:
43
49
44
- boxStore = MyObjectBox.builder().androidContext(this).build();
50
+ ``` java
51
+ boxStore = MyObjectBox . builder(). androidContext(this ). build();
52
+ ```
45
53
46
54
Create data object class ` @Entity ` , for example "Playlist".
47
55
Then get a ` Box ` class for this entity class:
48
-
49
- Box<Playlist > box = boxStore.boxFor(Playlist.class);
56
+
57
+ ``` java
58
+ Box<Playlist > box = boxStore. boxFor(Playlist . class);
59
+ ```
50
60
51
61
The ` Box ` object gives you access to all major functions, like ` put ` , ` get ` , ` remove ` , and ` query ` .
52
62
0 commit comments