Editing offline data

Offline data downloaded from a feature service and feature data in an offline map can be edited locally without a network connection. These local edits can later be synchronized with the source feature service when a network connection becomes available.

You can edit offline data from a feature service in the following ways:

  • Add, update, and delete features, non-spatial data, and related data.
  • Add and remove attachments.

The source feature service must have editing enabled.

When editing offline data downloaded from a feature service, the workflow is very similar to editing online data in the feature service over a network connection:

  • Offline data: edits are stored on device storage and you must synchronize the edits with the feature service. See Synchronizing edits for more information.
  • Online data: edits are stored in-memory and you must apply the edits to the feature service.

Add a feature

To add a new feature:

  1. Create an in-memory Feature by calling CreateFeature() on a Geodatabase Feature Table.

    ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)ArcGIS Maps SDK for Qt (QML)
    Use dark colors for code blocksCopy
                                                  
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    var newFeature = geodatabaseFeatureTable.CreateFeature();
    
    New features can also be created by providing a geometry and attributes, or from a Feature Template, a Feature Type, or a Feature Subtype. Feature Templates can be defined in ArcGIS Pro or in the Map Viewer. Feature Types and Feature Subtypes can be defined in ArcGIS Pro.
  2. Optionally modify the Feature's geometry and/or attributes.

    ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)ArcGIS Maps SDK for Qt (QML)
    Use dark colors for code blocksCopy
                                                  
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    newFeature.Geometry = new MapPoint(x: -0.1722, y: 51.5298, spatialReference: SpatialReferences.Wgs84);
    newFeature.SetAttributeValue("Name", "Lord's");
    
  3. Add the Feature to the offline data by calling AddFeature() on the Geodatabase Feature Table.

    ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)ArcGIS Maps SDK for Qt (QML)
    Use dark colors for code blocksCopy
                                                  
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    try
    {
        await geodatabaseFeatureTable.AddFeatureAsync(newFeature);
    }
    catch(Exception ex)
    {
        // Report the error
    }
    

Update a feature

To update an existing feature:

  1. Modify the geometry and/or attributes of the Feature.
    ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)ArcGIS Maps SDK for Qt (QML)
    Use dark colors for code blocksCopy
                                                  
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    existingFeature.Geometry = new MapPoint(x: -1.9025, y: 52.4559, spatialReference: SpatialReferences.Wgs84);
    existingFeature.SetAttributeValue("Name", "Edgbaston");
    
  2. Pass the modified feature to UpdateFeature() on the feature's Geodatabase Feature Table.
    ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)ArcGIS Maps SDK for Qt (QML)
    Use dark colors for code blocksCopy
                                                  
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    if (existingFeature.FeatureTable is FeatureTable featureTable)
    {
        try
        {
            await featureTable.UpdateFeatureAsync(existingFeature);
        }
        catch (Exception ex)
        {
            // Report the error
        }
    }
    

Delete a feature

To delete a feature:

  1. Pass the Feature to DeleteFeature() on the feature's Geodatabase Feature Table.
    ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)ArcGIS Maps SDK for Qt (QML)
    Use dark colors for code blocksCopy
                                                  
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    if (existingFeature.FeatureTable is FeatureTable featureTable)
    {
        try
        {
            await featureTable.DeleteFeatureAsync(existingFeature);
        }
        catch (Exception ex)
        {
            // Report the error
        }
    }

Editing capabilities

The owner of a feature service can configure how data can be edited. This configuration also affects offline data.

An offline application can read the configuration settings from the Geodatabase Feature Table to tailor the user experience. These are the properties that can be read, and the API object to read them from:

CheckHow to check using Geodatabase Feature Table
Is editing supported?Check the Editable property.
Can features be added?Check the Can Add Feature property.
Can geometries be edited?Check the Can Edit Geometry property.
Which attributes are editable?Check the Editable Attribute Fields property.
Can a specific feature be updated?Pass the Feature to the Can Update Feature method.
Can a specific feature be deleted?Pass the Feature to the Can Delete Feature method.

Transactions

A transaction allows you to group together multiple edits to feature layers, tables, and attachments in the same geodatabase. This supports offline applications that allow a number of related edits before the user decides whether to keep them or not.

Transactions are controlled on the Geodatabase. Only one transaction can be active at a time. A transaction must be committed or rolled back before offline data can be synchronized.

Transactions are tracked in the .geodatabase file stored on device's file system, so an application can return to a transaction that is in progress should the user switch away from or kill the application.

Synchronizing edits

To update a feature service with offline edits, you can synchronize the offline data with the source feature service. This can also update the offline data with edits in the feature service. To learn more, see Offline data: Synchronize and Offline maps: Synchronize.

Code examples

Rollback edits using a transaction

Use a transaction on a Geodatabase to group edits together for commits, or to enable rolling back edits to Geodatabase Feature Tables in that Geodatabase.

  1. Begin a transaction with the Geodatabase.
  2. Perform some edits (adds, updates, or deletes).
ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)ArcGIS Maps SDK for Qt (QML)
Use dark colors for code blocksCopy
                                        
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
try
{
    geodatabase.BeginTransaction();
}
catch (Exception ex)
{
    // Handle error - BeginTransaction will throw if another transaction is active
}

try
{
    await geodatabaseFeatureTable.DeleteFeatureAsync(existingFeature);
}
catch(Exception ex)
{
    // Handle error
}

var newFeature = geodatabaseFeatureTable.CreateFeature();

newFeature.Geometry = new MapPoint(x: 0.2638, y: 52.3987, spatialReference: SpatialReferences.Wgs84);
newFeature.SetAttributeValue("Name", "Ely cathedral");

try
{
    await geodatabaseFeatureTable.AddFeatureAsync(newFeature);
}
catch(Exception ex)
{
    // Handle error
}

Later, when the user decides to undo their edits, rollback the transaction with the Geodatabase.

ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)ArcGIS Maps SDK for Qt (QML)
Use dark colors for code blocksCopy
                                        
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
try
{
    geodatabase.RollbackTransaction();
}
catch(Exception ex)
{
    // Handle error - RollbackTransaction will throw if there is no active transaction
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.