View on GitHub Sample viewer app

Create a mobile geodatabase.

CreateMobileGeodatabase

Use case

A mobile geodatabase is a collection of various types of GIS datasets contained in a single file (.geodatabase) on disk that can store, query, and manage spatial and non-spatial data. Mobile geodatabases are stored in a SQLite database and can contain up to 2 TB of portable data. Users can create, edit and share mobile geodatabases across ArcGIS Pro, ArcGIS Maps SDKs for Native Apps, or any SQL software. These mobile geodatabases support both viewing and editing and enable new offline editing workflows without requiring a feature service.

For example, a user would like to track the location of their device at various intervals to generate a heat map of the most visited locations. The user can add each location as a feature to a table and generate a mobile geodatabase. The user can then instantly share the mobile geodatabase to ArcGIS Pro to generate a heat map using the recorded locations stored as a geodatabase feature table.

How to use the sample

Click “Create Geodatabase” to create the geodatabase and its feature table. Click on the map to add new features to the geodatabase. Click “View Table” to view the contents of the geodatabase feature table. Once you have added the features to the map, click on “Close Geodatabase” to save the .geodatabase file which can then be imported into ArcGIS Pro or opened with ArcGIS Maps SDKs for Native Apps.

How it works

  1. Create an empty mobile geodatabase with Geodatabase.createAsync(String path) and pass in a specific path as the parameter.
  2. Create a new TableDescription and add a list of new FieldDescriptions to its collection of field descriptions with tableDescription.getFieldDescriptions().addAll().
  3. Create a new table in the geodatabase from the table description with geodatabase.createTableAsync(). Once the listenable future has completed, get the newly created geodatabase feature table with geodatabaseFeatureTableFuture.get().
  4. Create a feature on the selected map point using geodatabaseFeatureTable.createFeature(), passing a map of feature attributes and a geometry as parameters.
  5. Add the feature to the table using geodatabaseFeatureTable.addFeatureAsync(feature).
  6. Each feature added to the geodatabase feature table is committed to the mobile geodatabase file.
  7. Close the mobile geodatabase with geodatabase.close().

Relevant API

  • ArcGISFeature
  • FeatureLayer
  • FieldDescription
  • Geodatabase
  • GeodatabaseFeatureTable
  • TableDescription

Additional information

Learn more about mobile geodatabases and how to utilize them on the ArcGIS Pro documentation page. The following mobile geodatabase behaviors are supported in the ArcGIS Maps SDKs for Native Apps: annotation, attachments, attribute rules, contingent values, dimensions, domains, feature-linked annotation, subtypes, utility network and relationship classes.

Learn more about the types of fields supported with mobile geodatabases on the ArcGIS Pro documentation page.

Tags

arcgis pro, database, feature, feature table, geodatabase, mobile geodatabase, sqlite

Sample Code

module-info.java module-info.java CreateMobileGeodatabaseController.java CreateMobileGeodatabaseSample.java FeatureAttributeField.java
/*
* Copyright 2022 Esri.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module com.esri.samples.create_mobile_geodatabase {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
// make all @FXML annotated objects reflectively accessible to the javafx.fxml module
opens com.esri.samples.create_mobile_geodatabase to javafx.fxml;
exports com.esri.samples.create_mobile_geodatabase;
}