Skip to content

DataStore

classDataStore

Persisted location record management — query, upload, and destroy stored locations.

Access via BGGeo.instance.store.


Members

all

suspend fun all(): List<Map<String, Any>>

Retrieve all LocationEvent records stored in the SDK's SQLite database.

// Within a coroutine scope
val bgGeo = BGGeo.instance

val locations = bgGeo.store.all()

count

val count: Int

Retrieve the count of all locations currently stored in the SDK's SQLite database.

val bgGeo = BGGeo.instance

val count = bgGeo.store.count

destroy

fun destroy(uuid: String)

Remove a single location by LocationEvent.uuid.

// Within a coroutine scope
val bgGeo = BGGeo.instance
val uuid = "some-location-uuid"
bgGeo.store.destroy(uuid)

destroyAll

fun destroyAll()

Remove all records from the SDK's SQLite database.

// Within a coroutine scope
val bgGeo = BGGeo.instance

bgGeo.store.destroyAll()

sync

suspend fun sync(): List<Map<String, Any>>

Manually upload all queued locations to HttpConfig.url.

Initiates a POST of all records in the SQLite database to your configured HttpConfig.url. Records that receive a 200 OK response are deleted from the database. If HttpConfig.batchSync is true, all locations are sent in a single request; otherwise one request is made per location. If no HTTP service is configured, all records are deleted from the database.

See also - HTTP Guide

// Within a coroutine scope
val bgGeo = BGGeo.instance

try {
    val records = bgGeo.store.sync()
    Log.d(TAG, "[sync] success: $records")
} catch (e: Exception) {
    Log.d(TAG, "[sync] FAILURE: $e")
}