I\'m trying to get data from Realm using an ID as a reference. However, when querying for an ID, I\'ve found that Realm is giving me the same ID for all elements (ID of 0).
if your Id is Long then:
val nextId = bgRealm.where(Branch::class.java).max("localId") as Long + 1