Skip to main content
Version: 1.x.x

RealtimeStore Methods - Android

set()

  • set() is used to store or update data in the RealtimeStore. If a key already exists, it will be overwritten with the new value. Passing null as the value deletes the key.

Parameters

  • key

    • type: String
    • The unique key to store the data under.
  • value

    • type: String?
    • The string value to be stored. Pass null to delete the key.
  • callback

    • type: RealtimeStoreCallback<String>
    • A callback that reports the success or failure of the operation.

Returns

  • void

Example

  meeting.realtimeStore.set("YOUR_KEY", message, object : RealtimeStoreCallback<String> {
override fun onSuccess(value: String) {
Log.d("VideoSDK", "Value: $value")
}

override fun onError(error: String) {
Log.e("VideoSDK", "Error: $error")
}
})

get()

  • get() retrieves the current value associated with a given key.

Parameters

  • key:

    • type: String
    • The key whose value you want to retrieve.
  • callback:

    • type: RealtimeStoreCallback<String>
    • A callback that provides the value on success or an error on failure.

Returns

  • void

Example

meeting.realtimeStore.get("YOUR_KEY", object : RealtimeStoreCallback<String> {
override fun onSuccess(value: String) {
Log.d("VideoSDK", "Value: $value")
}

override fun onError(error: String) {
Log.e("VideoSDK", "Error: $error")
}
})

observe()

  • observe() subscribes to real-time updates for a given key. When the key’s value changes, the onValueChanged method on your RealtimeStoreListener is triggered.

Parameters

  • key:

    • type: String
    • The key to observe.
  • listener:

    • type: RealtimeStoreListener
    • An object that will receive notifications about value changes.

Returns

  • void

Example

val realtimeStoreListener = object : RealtimeStoreListener {
override fun onValueChanged(newValue: String, updatedBy: Participant?) {
Log.d("VideoSDK", "onValueChange: Received update from: ${updatedBy.displayName}")
Log.d("VideoSDK", "onValueChange: New Value -> $newValue")
}
}

meeting.realtimeStore.observe(KEY_CHAT_HISTORY, realtimeStoreListener!!)

stopObserving()

  • stopObserving() stops receiving updates for a specific key and listener combination.

Parameters

  • key:

    • type: String
    • The key you want to stop observing.
  • listener:

    • type: RealtimeStoreListener
    • The listener that should be removed.

Returns

  • void

Example

meeting.realtimeStore.stopObserving("YOUR_KEY", realtimeStoreListener)

Got a Question? Ask us on discord