ArcGIS Runtime SDK for .NET Samples

Feature layer (geodatabase)

Feature layer to display a geodatabase table


// Copyright 2018 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:
// 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.

using Android.App;
using Android.OS;
using Android.Widget;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;
using ArcGISRuntime.Samples.Managers;

namespace ArcGISRuntime.Samples.FeatureLayerGeodatabase
        "Feature layer (geodatabase)",
        "This sample demonstrates how to consume an Esri .geodatabase file (aka. mobile geodatabase) by using a FeatureLayer and a GeodatabaseFeatureTable.",
        "The mobile geodatabase (.geodatabase file) will be downloaded from an ArcGIS Online portal automatically from the Url:",
    public class FeatureLayerGeodatabase : Activity
        // Create a reference to MapView.
        private MapView _myMapView;

        protected override void OnCreate(Bundle bundle)

            Title = "Feature layer (geodatabase)";


            // Open a mobile geodatabase (.geodatabase file) stored locally and add it to the map as a feature layer.

        private async void Initialize()
            // Create a new map to display in the map view with a streets basemap.
            _myMapView.Map = new Map(Basemap.CreateStreets());

            // Get the path to the downloaded mobile geodatabase (.geodatabase file).
            string mobileGeodatabaseFilePath = GetMobileGeodatabasePath();

            // Open the mobile geodatabase.
            Geodatabase mobileGeodatabase = await Geodatabase.OpenAsync(mobileGeodatabaseFilePath);

            // Get the 'Trailheads' geodatabase feature table from the mobile geodatabase.
            GeodatabaseFeatureTable trailheadsGeodatabaseFeatureTable = mobileGeodatabase.GeodatabaseFeatureTable("Trailheads");

            // Asynchronously load the 'Trailheads' geodatabase feature table.
            await trailheadsGeodatabaseFeatureTable.LoadAsync();

            // Create a feature layer based on the geodatabase feature table.
            FeatureLayer trailheadsFeatureLayer = new FeatureLayer(trailheadsGeodatabaseFeatureTable);

            // Add the feature layer to the operations layers collection of the map.

            // Zoom the map to the extent of the feature layer.
            await _myMapView.SetViewpointGeometryAsync(trailheadsFeatureLayer.FullExtent);

        private static string GetMobileGeodatabasePath()
            // Use samples viewer's DataManager helper class to get the path of the downloaded dataset on disk.
            // NOTE: The url for the actual data is:
            return DataManager.GetDataFolder("2b0f9e17105847809dfeb04e3cad69e0", "LA_Trails.geodatabase");

        private void CreateLayout()
            // Create a new vertical layout for the app.
            var layout = new LinearLayout(this) { Orientation = Orientation.Vertical };

            // Add a map view to the layout.
            _myMapView = new MapView(this);

            // Show the layout in the app.

In this topic
  1. Code