Skip to content

//sorisdk/com.iplateia.sorisdk/SORIAudioRecognizer/updateDatabase

updateDatabase

[androidJvm]
suspend fun updateDatabase(ctx: Context): UpdateResult

Updates the audio recognition database by checking for and downloading new audiopacks. This method can be called independently of the startRecognition method.

The method performs the following steps:

  1. Authenticates with the SORI API
  2. Checks if a database update is available
  3. Downloads the new audiopack if available
  4. Applies the update immediately if the recognition service is running
  5. Stores the update for later application if the service is not running

example usage:

kotlin
val recognizer = SORIAudioRecognizer("your_application_id", "your_secret_key")
CoroutineScope(Dispatchers.Main).launch {
    val result = recognizer.updateDatabase(this@MainActivity)
    if (result.success) {
        if (result.updateAvailable) {
            Log.d("SORI", "Database updated to version: ${result.currentVersion}")
        } else {
            Log.d("SORI", "Database is already up to date")
        }
    } else {
        Log.e("SORI", "Database update failed: ${result.errorMessage}")
    }
}

Return

UpdateResult containing the status of the update operation.

Parameters

androidJvm

ctxThe context from which the update is requested.