Docs Menu
Docs Home
/ /
Atlas Device SDKs
/
/
/

Field Types - Java SDK

On this page

  • Updating Strings and Byte Arrays
  • Object IDs and UUIDs

Realm supports the following field data types:

  • Boolean or boolean

  • Integer or int

  • Short or short

  • Long or long

  • Byte or byte[]

  • Double or double

  • Float or float

  • String

  • Date

  • Decimal128 from org.bson.types

  • ObjectId from org.bson.types

  • UUID from java.util.UUID

  • Any RealmObject subclass

  • RealmList

  • RealmAny

  • RealmSet

  • RealmDictionary

The Byte, Short, Integer, and Long types and their lowercase primitive alternatives are all stored as Long values within Realm. Similarly, Realm stores objects of the Float and float types as type Double.

Realm does not support fields with modifiers final and volatile, though you can use fields with those modifiers if you ignore them. If you choose to provide custom constructors, you must declare a public constructor with no arguments.

Since Realm operates on fields as a whole, it's not possible to directly update individual elements of strings or byte arrays. Instead, you'll need to read the whole field, make your modification to individual elements, and then write the entire field back again in a transaction block.

ObjectId and UUID (Universal Unique Identifier) both provide unique values that can be used as identifiers for objects. ObjectId is a MongoDB-specific 12-byte unique value. UUID is a standardized 16-byte unique value. Both types are indexable and can be used as primary keys.

← 
 →