GeodatabaseSyncTask class final
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 into a geodatabase. Here are the typical steps to download data from sync-enabled ArcGIS feature service into a geodatabase file on your device:
- Construct and load the GeodatabaseSyncTask with a URL to a sync-enabled ArcGIS feature service.
- Create a Geometry to define the area of interest that you wish to take offline.
- Obtain the GenerateGeodatabaseParameters for the area of interest by calling GeodatabaseSyncTask.createDefaultGenerateGeodatabaseParameters.
- Create a GenerateGeodatabaseJob by calling GeodatabaseSyncTask.generateGeodatabase. Specify a path where the mobile geodatabase (.geodatabase file) is downloaded to.
- Start the GenerateGeodatabaseJob. Upon job completion, obtain the Geodatabase from the GenerateGeodatabaseJob.result.
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:
- Create a GeodatabaseSyncTask with the Geodatabase.serviceUri.
- Obtain the SyncGeodatabaseParameters for the geodatabase by calling GeodatabaseSyncTask.createDefaultSyncGeodatabaseParameters.
- Create a SyncGeodatabaseJob by calling GeodatabaseSyncTask.syncGeodatabase). Specify the synchronization direction.
- Start the SyncGeodatabaseJob. Upon job completion, examine the SyncLayerResult from the SyncGeodatabaseJob.result to determine whether the synchronization was successful.
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:
- Create and load a Geodatabase from the downloaded geodatabase file using Geodatabase.withFileUri.
- Examine Geodatabase.isSyncEnabled to check that the geodatabase is sync-enabled. If this is false, no further action is needed.
- Create a GeodatabaseSyncTask with the Geodatabase.serviceUri.
- Unregister the geodatabase using GeodatabaseSyncTask.unregisterGeodatabase.
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. 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.
- Implemented types
- Mixed in types
Constructors
- GeodatabaseSyncTask.withUri(Uri uri)
-
Creates a geodatabase sync task object using a URL to a sync-enabled
ArcGIS feature service.
factory
Properties
- apiKey ↔ String
-
The API key allows your app to access ArcGIS location services and private
portal items.
getter/setter pairoverride
- featureServiceInfo → ArcGISFeatureServiceInfo?
-
Metadata about the ArcGIS feature service.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- loadError → ArcGISException?
-
The load error.
no setterinherited
- loadStatus → LoadStatus
-
The load status.
no setterinherited
-
onLoadStatusChanged
→ Stream<
LoadStatus> -
A stream that reports changes to the
LoadStatus
.no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- uri → Uri
-
The URL of the ArcGIS feature service.
no setter
Methods
-
cancelLoad(
) → void -
Cancels loading metadata for the object.
inherited
-
createDefaultGenerateGeodatabaseParameters(
{required Geometry extent}) → Future< GenerateGeodatabaseParameters> - Creates default parameters to generate and download a geodatabase using the GenerateGeodatabaseJob.
-
createDefaultSyncGeodatabaseParameters(
Geodatabase geodatabase) → Future< SyncGeodatabaseParameters> - Creates default parameters to synchronize a geodatabase using the SyncGeodatabaseJob.
-
createDefaultSyncGeodatabaseParametersWithSyncDirection(
{required Geodatabase geodatabase, required SyncDirection syncDirection}) → Future< SyncGeodatabaseParameters> - Creates default parameters for a sync geodatabase using the given sync direction.
-
generateGeodatabase(
{required GenerateGeodatabaseParameters parameters, required Uri pathToGeodatabaseFileUri}) → GenerateGeodatabaseJob - Returns a job to generate and download a geodatabase from an ArcGIS feature service.
-
load(
) → Future< void> -
Loads the metadata for the object asynchronously.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerSyncEnabledGeodatabase(
Geodatabase geodatabase) → Future< void> - Registers a copy of a sync-enabled geodatabase with an ArcGIS feature service to allow the copy to sync changes.
-
retryLoad(
) → Future< void> -
Loads or retries loading metadata for the object asynchronously.
inherited
-
syncGeodatabase(
{required SyncGeodatabaseParameters parameters, required Geodatabase geodatabase}) → SyncGeodatabaseJob - Returns a job to synchronize a geodatabase back to its source ArcGIS feature service.
-
syncGeodatabaseWithSyncDirection(
{required SyncDirection syncDirection, required bool rollbackOnFailure, required 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.
-
toString(
) → String -
A string representation of this object.
inherited
-
unregisterGeodatabase(
Geodatabase geodatabase) → Future< void> - Unregisters a geodatabase from its source ArcGIS feature service. This removes the services replica id.
-
unregisterGeodatabaseWithSyncId(
Guid syncId) → Future< void> - Unregisters a geodatabase from its source ArcGIS feature service using the geodatabases sync ID. This removes the services replica id.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
exportDelta(
{required Geodatabase geodatabase, required Uri outputUri}) → Future< bool> - Generates an upload delta geodatabase file containing all the changes since the last sync.
-
importDelta(
{required Geodatabase geodatabase, required Uri inputUri}) → Future< List< SyncLayerResult> > - Imports a geodatabase delta and applies it to the given geodatabase.