GeodatabaseSyncTask

A task to generate and synchronize a mobile geodatabase with a sync-enabled ArcGIS feature service. Mobile geodatabases are designed for querying and viewing feature data when your app is offline. While offline, users can edit a mobile geodatabase locally and later synchronize changes with its feature service, assuming the associated service supports synchronization. While offline, the geodatabase keeps track of all local edits. When you synchronize the geodatabase with the service, the service receives the geodatabase's local edits, and the geodatabase receives the service's remote edits.

This task allows you to build apps that can download data from an ArcGIS feature service that has been enabled for offline use[https://enterprise.arcgis.com/en/server/latest/publish-services/windows/prepare-data-for-offline-use.htm] into a geodatabase. Here are the typical steps to download data from sync-enabled ArcGIS feature service into a geodatabase file on your device:

The geodatabase may contain feature layers, annotation layers, related records, non-spatial tables, and attachments. You can create, update, or delete this data according to the capabilities of the source feature service. The geodatabase is registered with the online feature service so that you can synchronize their data when a network connection to the feature service is available. Your app business logic will determine whether the synchronization just downloads changes from the feature service (SyncDirection.Download), just uploads changes made to the geodatabase (SyncDirection.Upload), or uploads and downloads changes (SyncDirection.Bidirectional). Here are the typical steps to synchronize data between the geodatabase file and the source feature service:

When the geodatabase is no longer needed, you should unregister it to clean up the tracking metadata stored on the feature service. Unregistered geodatabases cannot be re-registered. Here are the steps to unregister a geodatabase:

There is another option for working with mobile geodatabases. You can place a copy of a sync-enabled geodatabase onto your device and register it with the associated service using GeodatabaseSyncTask.registerSyncEnabledGeodatabase(Geodatabase). This will give the geodatabase its own replica ID and you will be able to synchronize the geodatabase with its service.

If you want to download a portion of a web map and its content, instead of individual ArcGIS feature services, consider using the OfflineMapTask. You can then synchronize all of the map's geodatabase content together using the OfflineMapSyncTask.

Since

200.1.0

Constructors

Link copied to clipboard
constructor(url: String)

Creates a geodatabase sync task object using a URL to a sync-enabled ArcGIS feature service.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Metadata about the ArcGIS feature service. This information is available when the task is loaded.

Link copied to clipboard
val url: String

The URL of the ArcGIS feature service. This property is only writable when the task is in load status LoadStatus.NotLoaded.

Inherited properties

Link copied to clipboard
open override var apiKey: ApiKey?

An API key is a unique key used to authorize access to specific services and resources in ArcGIS Online. It is also used to monitor access to those services.

Link copied to clipboard
open override val loadStatus: StateFlow<LoadStatus>

The load status.

Functions

Creates default parameters to generate and download a geodatabase using the GenerateGeodatabaseJob. This populates the parameters with values that match the feature service. For example, if the service does not support SyncModel.Layer then SyncModel.Geodatabase will be used and all layers from the service will be included. Attachments are included by default, but related tables/layers are not included. Output features are in the spatial reference of the given extent.

Link copied to clipboard

Creates default parameters for a sync geodatabase using the given sync direction if it is not null.

Link copied to clipboard

Returns a job to generate and download a geodatabase from an ArcGIS feature service.

Link copied to clipboard

Returns a job to synchronize a geodatabase back to its source ArcGIS feature service. For a successfully completed job the job's result returns an array of SyncLayerResult, typically the array is empty. If individual edits failed then the result array provides these errors grouped by each table using SyncLayerResult instances which in turn contain each edit error.

fun createSyncGeodatabaseJob(syncDirection: SyncDirection, rollbackOnFailure: Boolean, geodatabase: Geodatabase): SyncGeodatabaseJob

Returns a job to synchronize a geodatabase back to its source ArcGIS feature service using the specified sync direction and rollback on failure boolean value. If the given sync direction is not compatible with the geodatabase sync task's feature service, the returned job will fail.

Link copied to clipboard

Registers a copy of a sync-enabled geodatabase with an ArcGIS feature service to allow the copy to sync changes. This method is typically used as part of services pattern workflow, sometimes known as a pre-planned workflow. A sync-enabled geodatabase is generated centrally and not modified or synced. Copies of this original geodatabase are distributed and loaded onto each user's device. The copy must first be registered with the service to allow the server to identify changes in subsequent sync operations. One of the main benefits of this workflow is a reduction in server load to generate geodatabases for many clients. It is important not to sync the copy before registering to ensure the server can maintain consistent state on each copy. This operation is not the opposite of GeodatabaseSyncTask.unregisterGeodatabase(Geodatabase) which is used to remove a geodatabase from the service prior to deletion.

Link copied to clipboard
suspend fun unregisterGeodatabase(syncId: Guid): Result<Unit>

Unregisters a geodatabase from its source ArcGIS feature service using the geodatabases sync ID. This removes the services replica id. This method is used to unregister a geodatabase from a service using the sync ID. This is commonly used to enable cleanup of the service after the local geodatabase has already been deleted. See Geodatabase.syncId. After unregistering a geodatabase it can no longer be synced back to the service. This operation is not related to GeodatabaseSyncTask.registerSyncEnabledGeodatabase(Geodatabase), which is for registering copies of a sync-enabled geodatabase.

suspend fun unregisterGeodatabase(geodatabase: Geodatabase): Result<Unit>

Unregisters a geodatabase from its source ArcGIS feature service. This removes the services replica id. After unregistering a geodatabase it can no longer be synced back to the service. This is often used prior to deleting a local geodatabase. This operation is not related to GeodatabaseSyncTask.registerSyncEnabledGeodatabase(Geodatabase), which is for registering copies of a sync-enabled geodatabase.

Inherited functions

Link copied to clipboard
open override fun cancelLoad()

Cancels loading metadata for the Loadable object.

Link copied to clipboard
open suspend override fun load(): Result<Unit>

Loads the metadata for the object.

Link copied to clipboard
open suspend override fun retryLoad(): Result<Unit>

Loads or retries loading metadata for the object.