Sync offline edits

Your users can edit offline in a services pattern and later sync their edits back to a feature service when connected. Syncing offline edits requires that you've created a geodatabase using a sync-enabled feature service from ArcGIS for Server, ArcGIS Online, or Portal for ArcGIS, as described in Create an offline map. After users have made edits and are ready to sync their local copy of the data with the service, use GeodatabaseSyncTask to sync with the feature service. Syncing can be performed even if no edits have been made locally, to pull changes from the feature service into the local copy of the data.

To synchronize edits, do the following:

  • Set up a callback to report on the progress while the synchronization happens.
  • Set up a callback to report when the process finishes or fails.
  • Create or obtain sync parameters for the synchronization task.
  • Create a GeodatabaseSyncTask instance.
  • Call the syncGeodatabase method on the GeodatabaseSyncTask using the callbacks and sync parameters you set up.
In a sync operation, edits most recently synced to the service will overwrite previously synced edits, regardless of time of edits.

For descriptions of errors that can arise when syncing offline edits, see Error handling with sync.

Register a geodatabase in a pre-planned workflow

In a services pattern workflow known as a pre-planned workflow, you generate the geodatabase once and load copies of it onto each user's device. If you've generated the geodatabase on the user's device with the generateGeodatabase() method on the GeodatabaseSyncTask class, you don't need to register a geodatabase.

In the pre-planned workflow, you use the registerGeodatabase() method to register each geodatabase copy (on each device) with the feature service you used to generate the original geodatabase. Registering in this way ensures each device receives the correct updates during sync operations.


  • Once you call unregister on a geodatabase, you cannot re-register the same geodatabase.
  • If the original geodatabase is ever unregistered, no additional clients can use that copy to register.

For a list of benefits of this workflow, see Register a geodatabase in a pre-planned workflow in "Create an offline map."

Code sample

The following sample shows how to sync your offline edits back to a feature service.

// ----------------------------------------------------------------
// Get your sync parameters from the geodatabase
// ----------------------------------------------------------------
final SyncGeodatabaseParameters syncParams = geodatabase.getSyncParameters();

// ----------------------------------------------------------------
// Set up your callbacks
// ----------------------------------------------------------------

// callback for displaying regular updates while the synchronization is taking place
GeodatabaseStatusCallback statusCallback = new GeodatabaseStatusCallback() {

  public void statusUpdated(GeodatabaseStatusInfo status) {
    System.out.println("Latest status: " + status.getStatus());

// callback that fires when the synchronization process completes or fails
CallbackListener<Map<Integer,GeodatabaseFeatureTableEditErrors>> syncResponseCallback = 
  new CallbackListener<Map<Integer,GeodatabaseFeatureTableEditErrors>>() {

  public void onError(Throwable e) {
    // report/handle the error as desired
    System.out.println("An error occurred: " + e.getLocalizedMessage());

  public void onCallback(Map<Integer,GeodatabaseFeatureTableEditErrors> errorMap) {
    // the Map returned by this method contains an entry for each layer 
    // and the layer's sync errors, if any

// ------------------------------------------------------------------------
// Create a GeodatabaseSyncTask
// ------------------------------------------------------------------------
// you may already have a GeodatabaseSyncTask object from generating a geodatabase
if (geodatabaseSyncTask == null) {
  geodatabaseSyncTask = new GeodatabaseSyncTask(FEATURE_SERVICE_URL, null);
// ------------------------------------------------------------------------
// Start sync
// ------------------------------------------------------------------------

Related topics