-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathjava.txt
216 lines (157 loc) · 7.19 KB
/
java.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
.. meta::
:robots: noindex, nosnippet
:template: product-landing
:hidefeedback: header
:noprevnext:
.. _java-intro:
.. _java-advanced-guides:
.. _java-usage-examples:
.. _java-fundamentals:
.. _java-realm-database:
=========================
Atlas Device SDK for Java
=========================
.. meta::
:description: Use the Atlas Device SDK for Java to store and sync data in Android apps using Java or Kotlin.
.. toctree::
:titlesonly:
Realm Files </sdk/java/realm-files>
Model Data </sdk/java/model-data>
CRUD </sdk/java/crud>
React to Changes </sdk/java/react-to-changes>
Adapters </sdk/java/adapters>
Asynchronous APIs </sdk/java/async-api>
Atlas App Services </sdk/java/app-services>
Manage Users </sdk/java/manage-users>
Sync Data </sdk/java/sync>
Test and Debug </sdk/java/test-and-debug>
Troubleshooting </sdk/java/troubleshooting>
SDK Telemetry </sdk/java/telemetry>
API Reference </sdk/java/api>
Kotlin Extensions API Reference <https://www.mongodb.com/docs/realm-sdks/java/latest/kotlin-extensions/>
Release Notes <https://github.com/realm/realm-java/blob/releases/CHANGELOG.md>
.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol
Use the Atlas Device SDK for Java to develop Android apps in Java or Kotlin.
To develop multiplatform apps using Kotlin Multiplatform (KMP), refer to the
:ref:`Kotlin SDK <kotlin-intro>`.
SDK in Maintenance Mode
-----------------------
This SDK is in best-effort maintenance mode and **no longer receives
new development or non-critical bug fixes**. To develop your app with new
features, use the :ref:`Kotlin SDK <kotlin-intro>`. You can use the Java SDK
with the Kotlin SDK.
Learn more about how to :ref:`<kotlin-migrate-from-java-sdk-to-kotlin-sdk>`.
.. kicker:: What You Can Do
Develop Apps with the SDK
-------------------------
Use the SDK's open-source database - Realm - as an object store on the device.
Use Device Sync to keep data in sync with your MongoDB Atlas cluster and
other clients.
.. tabs::
.. tab:: Store Data with the SDK
:tabid: device-persistence
.. procedure::
.. step:: Install the Java SDK
Use the Gradle build system to
:ref:`install the Java SDK in your project <java-install>`.
.. step:: Define an Object Schema
Use Java or Kotlin to idiomatically :ref:`define an object schema
<java-define-a-realm-object-schema>`.
.. step:: Open a Database
The SDK's database - Realm - stores objects in files on your device.
Or you can open an in-memory database which does not create a file.
To get started reading and writing data,
:ref:`configure and open a database <java-open-close-realm>`.
.. step:: Read and Write Data
:ref:`Create <java-create-a-new-object>`, :ref:`read
<java-read-from-realm>`, :ref:`update <java-update>`, and
:ref:`delete <java-delete-an-object>` objects from the database.
Use Android-native queries to :ref:`filter data
<java-client-query-engine>`.
.. step:: React to Changes
Live objects mean that your data is always up-to-date.
You can :ref:`register a notification handler
<java-react-to-changes>` to watch for changes and perform some
logic, such as updating your UI.
.. image:: /images/illustrations/2024_branding/Technical_SOFTWARE_Connect(2)_Spot.png
:alt: Atlas Device SDK Mobile Illustration
.. tab:: Sync Data Across Devices
:tabid: device-sync
.. procedure::
.. step:: Connect to an Atlas App Services App
Configure :ref:`Device Sync in an App Services App
<realm-sync-get-started>`. Define data access rules. Use
Development Mode to infer your schema from your Java or
Kotlin data model.
Then, :ref:`connect to the backend <java-init-appclient>` from
your client.
.. step:: Authenticate a User
Use one of our authentication providers to :ref:`authenticate a
user <java-authenticate-users>`. App Services provides access
to popular authentication providers, such as Apple, Google, or
Facebook. Use our built-in email/password provider to manage
users without a third-party, or use custom JWT authentication to
integrate with other authentication providers. Anonymous authentication
provides access without requiring a login or persisting user data.
.. step:: Open a Synced Database
:ref:`Configure and open a synced database <java-synced-realms>`.
:ref:`Subscribe to a query <java-sync-subscribe-to-queryable-fields>`
to determine what data the synced database can read and write.
.. step:: Read and Write Synced Data
The APIs to read and write data are the same whether you're
using a synced or non-synced database. Data that you
read and write is automatically kept in sync with your Atlas
cluster and other clients. Apps keep working offline and
deterministically sync changes whenever a network connection is
available.
.. image:: /images/illustrations/2024_branding/Technical_SOFTWARE_Sync(2)_Spot.png
:alt: Device Sync Illustration
.. tab:: Build with Atlas App Services
:tabid: app-services
.. container::
Call Serverless Functions
~~~~~~~~~~~~~~~~~~~~~~~~~
You can :ref:`call serverless Functions <java-call-a-function>`
from your client application that run in an App Services backend.
Query MongoDB Atlas
~~~~~~~~~~~~~~~~~~~
You can :ref:`query data stored in MongoDB <java-mongodb-data-access>`
directly from your client application code.
Authenticate Users
~~~~~~~~~~~~~~~~~~
Authenticate users with built-in and third-party :ref:`authentication
providers <java-authenticate-users>`. Use the authenticated user to
access App Services.
.. image:: /images/illustrations/2024_branding/Technical_ACTION_WrenchSettings_Spot.png
:alt: App Services Illustration
.. kicker:: Essential Documentation
Recommended Reading
-------------------
.. card-group::
:columns: 3
:style: extra-compact
.. card::
:headline: Java Quick Start
:cta: Explore the Quick Start
:url: https://www.mongodb.com/docs/realm/sdk/java/quick-start-local/
:icon: general_content_tutorial
:icon-alt: Tutorial Icon
Get started with the Java SDK.
.. card::
:headline: Java API Reference
:cta: Java API Reference
:url: https://www.mongodb.com/docs/realm-sdks/java/latest/
:icon: realm_sdk
:icon-alt: Atlas Device SDK Icon
Explore generated reference docs for the SDK's Java APIs.
.. card::
:headline: Kotlin Extensions API Reference
:cta: Kotlin Extensions Reference
:url: https://www.mongodb.com/docs/realm-sdks/java/latest/kotlin-extensions/
:icon: realm_sdk
:icon-alt: Atlas Device SDK Icon
Explore generated reference docs for the Kotlin Extensions APIs.