Skip to main content

Sync Database

It serves as the entry point to access SyncDatabase.
After initialization, call getInstance() to obtain the instance of SyncDatabase associated with the database. Use document() to read and write documents in SyncDatabase.

Summary

Public companion functions
InitializationState
initialize(application: Application, syncConfigsProvider: SyncConfigsProvider)

SyncDatabase Initializes SyncDatabase synchronously.

Unit
initialize(application: Application, syncConfigsProvider: SyncConfigsProvider, listener: DatabaseListener)

SyncDatabase Initializes SyncDatabase asynchronously (callback-based).

SyncDatabase?
getInstance(databaseName: String)

SyncDatabase Returns an instance of SyncDatabase connected to the specified database.

Unit
dispose()

Cleans up all connections and resources of SyncDatabase.


Public methods
SyncDocument
document(@NonNull String documentName)

Returns the document of the specified database.


Public methods

initialize()
initialize(application: Application, syncConfigsProvider: SyncConfigsProvider)

Initializes SyncDatabase synchronously.

Parameters

application: Application

Application

syncConfigsProvider: SyncConfigsProvider

Provider that supplies the necessary information for initializing SyncDatabase. The provider analyzes the config file downloaded from Playground located in the project's assets folder and constructs the initialization information.

databaseListener: DatabaseListener

A listener that receives information about the initialization result of SyncDatabase and its state asynchronously.


initialize()
initialize(application: Application, syncConfigsProvider: SyncConfigsProvider, listener: DatabaseListener)

Initializes SyncDatabase asynchronously (callback-based).

Parameters

application: Application

Application

syncConfigsProvider: SyncConfigsProvider

A provider that supplies the information required to initialize SyncDatabase.

The provider analyzes the config file downloaded from Playground in the assets folder of the project to construct and provide initialization information.

databaseListener: DatabaseListener

A listener that receives the result of the asynchronous SyncDatabase initialization and provides information about the state of the SyncDatabase.


getInstance()
getInstance(databaseName: String)

Returns an instance of SyncDatabase associated with the specified database.

Parameters

databaseName: String

The name of the database you want to access — this is the name you entered when applying in Playground.

Returns
SyncDatabase?

An instance of SyncDatabase linked to the specified database.


dispose()
fun dispose()

Cleans up all connections and resources of SyncDatabase, making SyncDatabase and SyncDocument unusable.

Public methods

document()
@Throws(SyncException::class)
fun document(documentName: String): SyncDocument

Returns the document of the specified database.

Parameters

documentName: String

Name of the document to be used

Returns
SyncDocument

SyncDocument object representing the document

[Limitation]

The length of the document name must be between 2 and 200 bytes.