Class Geodatabase

java.lang.Object
com.esri.arcgisruntime.data.Geodatabase
All Implemented Interfaces:
Loadable

public final class Geodatabase extends Object implements Loadable
A mobile geodatabase containing geographic data and non-spatial tables.

Geodatabase is used to open and access the contents of a mobile geodatabase (.geodatabase file) that can contain geographic features, non-spatial tabular data, and data such as attachments, utility networks, field domain definitions, contingent values, and relationships between layers/tables.

Geodatabases can contain one or more geodatabase feature tables. You can create a layer from a GeodatabaseFeatureTable, as follows:

You can generate a mobile geodatabase file from an ArcGIS feature service and download it to a device using offline workflows offered by the GeodatabaseSyncTask and the OfflineMapTask. Apps can then operate offline to view and edit the features in these geodatabases. If the geodatabases are enabled for synchronization with the original feature service, edits can be synchronized when connectivity is restored.

Mobile geodatabase files can also be created with ArcGIS Pro. These geodatabases can be used offline but they do not support synchronization with the original feature service. See Build offline applications for more information.

Since:
100.0.0
  • Property Details

  • Constructor Details

    • Geodatabase

      public Geodatabase(String geodatabasePath)
      Creates a geodatabase object with the given path.

      If the specified path points to a stand-alone mobile geodatabase created with ArcGIS Pro and contains a controller dataset, such as a utility network or parcel fabric, the feature tables on this geodatabase are read-only. The presence of utility networks can be checked using getUtilityNetworks().

      Parameters:
      geodatabasePath - path to geodatabase (including .geodatabase file extension).
      Throws:
      IllegalArgumentException - if path is null
      Since:
      100.0.0
  • Method Details

    • getGeodatabaseFeatureTables

      public List<GeodatabaseFeatureTable> getGeodatabaseFeatureTables()
      Gets a list of GeodatabaseFeatureTable from the geodatabase that contain geometries, such as points, lines or polygons.

      Feature tables in this list are read-only when the geodatabase is a stand-alone mobile geodatabase created with ArcGIS Pro and tables participate in a controller dataset, such as utility network or parcel fabric. The presence of utility networks can be checked using getUtilityNetworks().

      The returned list will be empty if the geodatabase is not loaded.

      Returns:
      a list of GeodatabaseFeatureTable from the geodatabase that contain geometries, such as points, lines or polygons
      Since:
      100.0.0
    • getGeodatabaseFeatureTable

      public GeodatabaseFeatureTable getGeodatabaseFeatureTable(String name)
      Gets a feature table containing point, line, or polygon features from the geodatabase, as specified by the given name.
      Parameters:
      name - the name of the geodatabase feature table containing point, line, or polygon features
      Returns:
      the specified geodatabase feature table, or null if the specified table does not exist or contains annotation or dimension feature data
      Since:
      100.0.0
      See Also:
    • getGeodatabaseFeatureTableByServiceLayerId

      public GeodatabaseFeatureTable getGeodatabaseFeatureTableByServiceLayerId(int layerId)
      Returns a feature table from the geodatabase containing point, line or polygon features, as specified by the given feature service layer ID.

      The feature table returned is read-only when the geodatabase is a stand-alone mobile geodatabase created with ArcGIS Pro and the table participates in a controller dataset, such as a utility network or parcel fabric. The presence of utility networks can be checked using getUtilityNetworks().

      Parameters:
      layerId - the service layer ID of the geodatabase feature table
      Returns:
      if the given layer ID matches a table in the geodatabase containing annotation or dimension feature data, then no table is returned, or null if none
      Since:
      100.0.0
    • getGeodatabaseAnnotationTables

      public List<GeodatabaseFeatureTable> getGeodatabaseAnnotationTables()
      Gets an unmodifiable list of GeodatabaseFeatureTable from the geodatabase that contain annotation features.

      The list will be empty if the Geodatabase is not loaded.

      Returns:
      a list of GeodatabaseFeatureTable from the geodatabase that contain annotation features
      Since:
      100.6.0
      See Also:
    • getGeodatabaseAnnotationTable

      public GeodatabaseFeatureTable getGeodatabaseAnnotationTable(String name)
      Gets a feature table containing annotation features from the geodatabase, as specified by the given name.
      Parameters:
      name - the name of the geodatabase feature table containing annotation features
      Returns:
      the specified geodatabase feature table, or null if the specified table does not exist or does not contain annotation feature data
      Since:
      100.6.0
      See Also:
    • getGeodatabaseAnnotationTableByServiceLayerId

      public GeodatabaseFeatureTable getGeodatabaseAnnotationTableByServiceLayerId(int layerId)
      Gets a feature table containing annotation features from the geodatabase, as specified by the given feature service layer ID.

      The service layer ID must match ArcGISFeatureLayerInfo.getServiceLayerId().

      Parameters:
      layerId - the service layer ID of the geodatabase feature table
      Returns:
      the specified geodatabase feature table, or null if the specified table does not exist or does not contain annotation feature data
      Since:
      100.6.0
      See Also:
    • hasLocalEdits

      public boolean hasLocalEdits()
      Indicates if the geodatabase has local edits. True if the geodatabase has local edits, false otherwise.

      If the geodatabase was created by ArcGIS Pro, this method returns false because there is no concept of uploading or applying edits. If you want to determine which tables have local edits, examine GeodatabaseFeatureTable.hasLocalEditsSince(Calendar).

      Returns:
      true if there are local edits, false otherwise
      Since:
      100.0.0
    • getServiceUrl

      public String getServiceUrl()
      Gets the service URL from which the geodatabase was obtained.
      Returns:
      the service URL from which the geodatabase was obtained
      Since:
      100.0.0
    • getSyncId

      public UUID getSyncId()
      Gets the sync ID of the geodatabase. Sync ID is available if isSyncEnabled() is true. The sync ID is the same as the replica ID described in the REST documentation. It is used by the geodatabase's service to uniquely identify the geodatabase when carrying out sync operations. It is also used to unregister the geodatabase using the GeodatabaseSyncTask.unregisterGeodatabaseAsync(UUID).
      Returns:
      Sync ID of the given geodatabase or null if there is an error. Will also return null if this is not a sync enabled geodatabase or if the geodatabase is not loaded.
      Since:
      100.6.0
      See Also:
    • getSyncModel

      public SyncModel getSyncModel()
      Gets the sync model defining how datasets within the geodatabase are synchronized with the originating ArcGIS feature service. This was set when the geodatabase was created and determines how updates can be synced with the service. If the sync model is PER_GEODATABASE, layers cannot be synced independently: the whole geodatabase must be synced in one operation.

      Sync model only applies to the geodatabase if isSyncEnabled() is true.

      If the sync model is PER_LAYER, layers can be synced independently of one another.

      Returns:
      the geodatabase's sync model
      Since:
      100.0.0
    • isSyncEnabled

      public boolean isSyncEnabled()
      True if the geodatabase was originally downloaded from a sync-enabled ArcGIS feature service, false otherwise.

      A sync-enabled geodatabase can be requested from an ArcGIS feature service using the GenerateGeodatabaseJob or the GenerateOfflineMapJob. It can also be downloaded as part of a PreplannedMapArea. See GeodatabaseSyncTask and OfflineMapTask for more information.

      If true, the geodatabase's data can be synchronized with its original ArcGIS feature service.

      Returns:
      true if sync is enabled, false otherwise
      Since:
      100.0.0
      See Also:
    • getDomains

      public ListenableList<Domain> getDomains()
      Returns a list of the domains that exist in the geodatabase.

      The returned list will be empty if the geodatabase itself is not loaded.

      Returns:
      returns a list of the domains that exist in the geodatabase
      Since:
      100.14.0
    • getGenerateGeodatabaseGeometry

      public Geometry getGenerateGeodatabaseGeometry()
      Gets the geometry that was used to generate the sync-enabled geodatabase.

      If the geodatabase was created using the GenerateGeodatabaseJob, the geometry matches the GenerateGeodatabaseParameters.getExtent(). If the geodatabase was created using the GenerateOfflineMapJob, the geometry reflects the GenerateOfflineMapParameters.getAreaOfInterest(). If the geodatabase was downloaded as part of a PreplannedMapArea, this method will return the geometry used by the web map author when the offline map area was created. See Build offline applications for more information on taking data offline.

      Edits made to a sync-enabled Geodatabase must intersect this geometry. If an edit is made outside this extent, or area of interest, it will be rejected.

      This method returns null if the geodatabase was authored using ArcGIS Pro or if the getLoadStatus() is not LoadStatus.LOADED.

      Returns:
      the geometry used to generate a sync enabled geodatabase, or null if the geodatabase is not sync enabled
      Since:
      100.7.0
    • getPath

      public String getPath()
      Returns the path to the geodatabase.
      Returns:
      the geodatabase path
      Since:
      100.2.0
    • getUtilityNetworks

      public List<UtilityNetwork> getUtilityNetworks()
      Gets an unmodifiable list of UtilityNetwork objects that are packaged within the Geodatabase.

      The returned list will be empty if the geodatabase is not loaded or if no utility networks exist in the geodatabase.

      Returns:
      the list of UtilityNetwork objects that are packaged within the Geodatabase
      Since:
      100.11.0
    • getUtilityNetwork

      public UtilityNetwork getUtilityNetwork(String utilityNetworkName)
      Returns an UtilityNetwork from the geodatabase with the specified utility network name.
      Parameters:
      utilityNetworkName - the name of the utility network
      Returns:
      if the specified utility network is not found, then null is returned
      Throws:
      IllegalArgumentException - if utilityNetworkName is null
      Since:
      100.11.0
    • close

      public void close()
      Closes the connection to the geodatabase.

      You should stop using the geodatabase before you close it. For example, you should terminate geodatabase synchronization, remove feature layers from maps, and release the feature tables. Any attempt to access the geodatabase after it is closed will fail, resulting in an error. After closing a geodatabase, you can delete the geodatabase file from the device.

      Since:
      100.1.0
    • isInTransaction

      public boolean isInTransaction()
      Gets whether a transaction is active on the geodatabase. True if a transaction is active on the geodatabase, false otherwise.

      A transaction manages a series of geodatabase edits as a single unit of work. You can start a transaction by calling beginTransaction(). All edits made after this call are part of the transaction.

      A geodatabase transaction stays active until you end it by calling commitTransaction() or rollbackTransaction(). Geodatabase.commitTransaction() saves all edits in the transaction to the geodatabase and ends the transaction. Geodatabase.rollbackTransaction() discards all edits in the transaction and ends the transaction.

      If the app unexpectedly disconnects from the database, any active transaction will be rolled back. If the app crashes, or the user closes the app without saving edits, the transaction will be rolled back and the edits discarded.

      Returns:
      true if a transaction is active on the geodatabase, otherwise false
      Since:
      100.2.0
      See Also:
    • createAsync

      public static ListenableFuture<Geodatabase> createAsync(String path)
      Creates an empty mobile geodatabase at the specified path.

      The path must be non-empty, available, allow read/write access, and end in ".geodatabase". If any of these restrictions are violated, the task will not succeed and a task error will be set.

      Parameters:
      path - the path at which the mobile geodatabase is created
      Returns:
      a ListenableFuture that returns a Geodatabase in a loaded state, if one was able to be created at the specified path
      Throws:
      IllegalArgumentException - if path is null
      Since:
      100.14.0
    • createDomainAsync

      public ListenableFuture<Domain> createDomainAsync(DomainDescription domainDescription)
      Creates a new domain in the geodatabase.

      Creating domains is only supported in mobile geodatabases (either created in Pro or via createAsync(String)). The Field.Type of the domain cannot be unknown. The domain name must not already exist in the geodatabase. For additional domain name constraints, see DomainDescription.getName().

      Parameters:
      domainDescription - the description of the domain to create
      Returns:
      a ListenableFuture that returns a Domain if one was able to be created
      Throws:
      IllegalArgumentException - if domainDescription is null
      Since:
      100.14.0
    • deleteDomainAsync

      public ListenableFuture<Void> deleteDomainAsync(String domainName)
      Deletes the domain with the specified name from the geodatabase.

      Deleting domains is only supported in mobile geodatabases (either created in Pro or via createAsync(String)). The domain with the specified name must exist in the geodatabase. The domain must not be in use by any fields in existing tables.

      Parameters:
      domainName - the name of the domain to delete
      Returns:
      a ListenableFuture with no return value. If there is no error, the domain was deleted successfully.
      Throws:
      IllegalArgumentException - if domainName is null
      Since:
      100.14.0
    • createTableAsync

      public ListenableFuture<GeodatabaseFeatureTable> createTableAsync(TableDescription tableDescription)
      Creates a new table in the geodatabase.

      Creating tables is only supported in mobile geodatabases (either created in Pro or via createAsync(String)). The table name must not already exist in the geodatabase. For additional table name constraints, see TableDescription.getTableName().

      Parameters:
      tableDescription - the description of the table to create
      Returns:
      a ListenableFuture that returns a GeodatabaseFeatureTable in a loaded state, if one was able to be created
      Throws:
      IllegalArgumentException - if tableDescription is null
      Since:
      100.14.0
    • deleteTableAsync

      public ListenableFuture<Void> deleteTableAsync(String tableName)
      Deletes an existing table from the geodatabase.

      Deleting tables is only supported in mobile geodatabases created in ArcGIS Pro or using createAsync(String). Attempting further use of a deleted table, such as rendering it in a feature layer or querying it, may result in errors.

      Parameters:
      tableName - the name of the table to delete
      Returns:
      a ListenableFuture with no return value. If there is no error, the table was deleted successfully.
      Throws:
      IllegalArgumentException - if tableName is null
      Since:
      100.14.0
    • beginTransaction

      public void beginTransaction()
      Starts a transaction on the geodatabase.

      This method starts a new transaction on the geodatabase. The transaction fails to begin if another transaction is already active. A geodatabase cannot be synchronized while a transaction is active.

      Transactions can be started and stopped on any thread. Any edits that take place after a call to beginTransaction() but before a call to either commitTransaction() or rollbackTransaction() will be considered part of that transaction, no matter what thread made the edit.

      Since:
      100.2.0
    • commitTransaction

      public void commitTransaction()
      Commits the edits in the current transaction to the geodatabase. This will also end the transaction.

      An exception will be thrown if a transaction has not been started on the geodatabase.

      Transactions can be started and stopped on any thread. Any edits that take place after a call to beginTransaction() but before a call to either commitTransaction() or rollbackTransaction() will be considered part of that transaction, no matter what thread made the edit.

      Since:
      100.2.0
    • rollbackTransaction

      public void rollbackTransaction()
      Rollback the edits in the current transaction from the geodatabase.

      An exception will be thrown if a transaction has not been started on the geodatabase.

      Transactions can be started and stopped on any thread. Any edits that take place after a call to beginTransaction() but before a call to either commitTransaction() or rollbackTransaction() will be considered part of that transaction, no matter what thread made the edit.

      Since:
      100.2.0
    • addTransactionStatusChangedListener

      public void addTransactionStatusChangedListener(Geodatabase.TransactionStatusChangedListener listener)
      Parameters:
      listener - the TransactionStatusChangedListener to add
      Throws:
      IllegalArgumentException - if the listener is null
      Since:
      100.2.0
    • removeTransactionStatusChangedListener

      public boolean removeTransactionStatusChangedListener(Geodatabase.TransactionStatusChangedListener listener)
      Removes the Geodatabase.TransactionStatusChangedListener from the Geodatabase.
      Parameters:
      listener - the TransactionStatusChangedListener to remove
      Returns:
      true if listener has been removed, otherwise false
      Since:
      100.2.0
    • getMinServerGeneration

      public long getMinServerGeneration()
      Returns the minimum server generation number for the geodatabase.

      Server generation numbers indicate the state of a geodatabase (or individual layers) with respect to changes which have been synced with the online service. The number increases as new changes from the online feature service are synced to the local geodatabase. If getSyncModel() is SyncModel.PER_GEODATABASE, the value will indicate the server generation number for the entire geodatabase. If the getSyncModel() is SyncModel.PER_LAYER, the value will be the lowest server generation number for all of the layers in the geodatabase. This property will be -1 if the geodatabase does not support sync (SyncModel.NONE).

      This property will be -1 until the geodatabase is LoadStatus.LOADED.

      Note that this property is only required when using advanced workflows to manually apply pre-generated changes and not when performing a sync directly against the online service.

      Returns:
      the minimum server generation number for the geodatabase
      Since:
      100.6.0
    • getGeodatabaseDimensionTables

      public List<GeodatabaseFeatureTable> getGeodatabaseDimensionTables()
      Gets a list of GeodatabaseFeatureTable from the geodatabase that contain dimension features.

      The returned list will be empty if the geodatabase is not loaded.

      Returns:
      a list of GeodatabaseFeatureTable from the geodatabase that contain dimension features
      Since:
      100.13.0
    • getGeodatabaseDimensionTable

      public GeodatabaseFeatureTable getGeodatabaseDimensionTable(long serviceLayerId)
      Returns a feature table containing dimension features from the geodatabase, as specified by the given feature service layer ID.

      The service layer ID must match the ArcGISFeatureLayerInfo.getServiceLayerId().

      Parameters:
      serviceLayerId - the service layer ID of the geodatabase feature table containing dimension features
      Returns:
      a GeodatabaseFeatureTable object or null if the specified table does not contain dimension feature data
      Since:
      100.13.0
    • getGeodatabaseDimensionTable

      public GeodatabaseFeatureTable getGeodatabaseDimensionTable(String tableName)
      Returns a feature table containing dimension features from the geodatabase, as specified by the given tableName.
      Parameters:
      tableName - the name of the geodatabase feature table containing dimension features
      Returns:
      a GeodatabaseFeatureTable object or null if the specified table does not contain dimension feature data
      Throws:
      IllegalArgumentException - if tableName is null or empty
      Since:
      100.13.0
    • getLoadStatus

      public LoadStatus getLoadStatus()
      Gets the value of the loadStatus property.
      Specified by:
      getLoadStatus in interface Loadable
      Property description:
      Returns:
      the value of the loadStatus property
      See Also:
    • getLoadError

      public ArcGISRuntimeException getLoadError()
      Gets the value of the loadError property.
      Specified by:
      getLoadError in interface Loadable
      Property description:
      Returns:
      the value of the loadError property
      See Also:
    • cancelLoad

      public void cancelLoad()
      Description copied from interface: Loadable
      Cancels loading metadata for the object.

      Cancels loading the metadata if the object is loading, and always invokes the done loading listener.

      A load operation that is in progress (LoadStatus.LOADING state) can be cancelled by calling this method and the resource will transition from LoadStatus.LOADING to LoadStatus.FAILED_TO_LOAD state. If the load operation was successfully cancelled, a CancellationException will be returned from Loadable.getLoadError().

      Cancellation should be used carefully because all enqueued done loading listeners for that resource instance will get invoked with an error stating that the operation was cancelled. Thus, one component in the application can cancel the load operation initiated by other components.

      This method does nothing if the resource is not in LoadStatus.LOADING state.

      Specified by:
      cancelLoad in interface Loadable
    • loadAsync

      public void loadAsync()
      Description copied from interface: Loadable
      Loads the metadata of the loadable resource asynchronously.

      The load status changes from LoadStatus.NOT_LOADED to LoadStatus.LOADING. A listener can be added via Loadable.addDoneLoadingListener(java.lang.Runnable) that is invoked upon completion of the asynchronous load operation.

      If the load operation completes successfully, the load status will be LoadStatus.LOADED, which means the resource has loaded its metadata.

      If the load operation failed, the load status will be LoadStatus.FAILED_TO_LOAD and the error can be retrieved by calling Loadable.getLoadError().

      This method can be called concurrently and repeatedly, but only one attempt is ever made to perform the load operation. If a load operation is already in progress (LoadStatus.LOADING state) when loadAsync is called, it simply piggy-backs on the outstanding operation and the done loading listener added to the loadable resource is enqueued to be invoked when that operation completes. If the operation has already completed (LoadStatus.LOADED or LoadStatus.FAILED_TO_LOAD state) when loadAsync is called, the done loading listener is immediately invoked when added to the loadable resource.

      If a loadable resource has failed to load, calling loadAsync on it subsequently will not change its state. The done loading listener will be invoked immediately when added to the loadable resource. In order to retry loading the resource, Loadable.retryLoadAsync() needs to be used.

      A load operation that is in progress (LoadStatus.LOADING state) can be cancelled by calling Loadable.cancelLoad().

      Specified by:
      loadAsync in interface Loadable
    • retryLoadAsync

      public void retryLoadAsync()
      Description copied from interface: Loadable
      Loads or retries loading metadata for the object asynchronously.

      Will retry loading the metadata if the object's load status is LoadStatus.FAILED_TO_LOAD. Will load the object if it is not loaded. Will not retry to load the object if the object is loaded.

      For more details on the load process see Loadable.loadAsync().

      Specified by:
      retryLoadAsync in interface Loadable
    • addDoneLoadingListener

      public void addDoneLoadingListener(Runnable listener)
      Description copied from interface: Loadable
      Adds a listener to the loadable resource that is invoked when loading has completed.

      The listener may be added at any point, whether the loadable resource has already completed loading or not.

      • For resources that are not loaded when the listener is added (LoadStatus is NOT_LOADED or LOADING): When the resource completes loading, the listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
      • For resources that are already loaded when the listener is added (LoadStatus is LOADED or FAILED_TO_LOAD): The listener will be called immediately, on the current thread.

      Alternatively, to be notified when there is any change in the load status, add a listener to the Loadable.loadStatusProperty() instead.

      Specified by:
      addDoneLoadingListener in interface Loadable
      Parameters:
      listener - a Runnable that is invoked upon completion of the load operation
    • removeDoneLoadingListener

      public boolean removeDoneLoadingListener(Runnable listener)
      Description copied from interface: Loadable
      Removes a done loading listener from the loadable resource.
      Specified by:
      removeDoneLoadingListener in interface Loadable
      Parameters:
      listener - the listener to be removed
      Returns:
      true if the listener was removed, otherwise false
    • addLoadStatusChangedListener

      public void addLoadStatusChangedListener(LoadStatusChangedListener listener)
      Description copied from interface: Loadable
      Adds a LoadStatusChangedListener to the loadable resource that is invoked whenever the load status changes.

      Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.

      The listener will not be called if added to a loadable resource that has already completed loading. To be notified when a loadable resource has completed loading, including if the resource is already loaded when the listener is added, use the Loadable.addDoneLoadingListener(Runnable) method.

      Specified by:
      addLoadStatusChangedListener in interface Loadable
      Parameters:
      listener - the LoadStatusChangedListener to be added
    • removeLoadStatusChangedListener

      public boolean removeLoadStatusChangedListener(LoadStatusChangedListener listener)
      Description copied from interface: Loadable
      Removes a LoadStatusChangedListener from the loadable resource.
      Specified by:
      removeLoadStatusChangedListener in interface Loadable
      Parameters:
      listener - the LoadStatusChangedListener to be removed
      Returns:
      true if the listener was removed, otherwise false
    • loadStatusProperty

      public ReadOnlyObjectProperty<LoadStatus> loadStatusProperty()
      Description copied from interface: Loadable
      The load status.
      Specified by:
      loadStatusProperty in interface Loadable
      Returns:
      the loadStatus property
      See Also:
    • loadErrorProperty

      public ReadOnlyObjectProperty<ArcGISRuntimeException> loadErrorProperty()
      Description copied from interface: Loadable
      The load error.
      Specified by:
      loadErrorProperty in interface Loadable
      Returns:
      the loadError property
      See Also: