How to open a Mobile Geodatabase?

805
2
12-17-2020 02:29 PM
KirkKuykendall1
Occasional Contributor III

Hi -

I get an exception trying to open a mobile geodatabase.

Is there a snippet for this somewhere?

Thanks, Kirk

 

public static void Test3()
{
    var mgdbPath = @"D:\nhd_data\Mobile2.geodatabase";
    if (!File.Exists(mgdbPath))
        throw new FileNotFoundException(mgdbPath);
    var cn = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLite)
    { 
        Database = mgdbPath //anything else to set??
    };

    using (var gdb = new Geodatabase(cn)) //exception here
    {
        var c = gdb.GetDefinitions<FeatureClassDefinition>().Count();
        Debug.Print($"count {c}");
    }
}

 

0 Kudos
2 Replies
RichRuh
Esri Regular Contributor

Hi Kirk,

The Pro SDK doesn't yet support directly opening mobile geodatabases.  You can get a feature class or table that comes from a mobile geodatabase by getting it from the map, and you can open a SQLite database as a Database using Database(SQLiteConnectionPath), but that doesn't give you the same capabilities.

We're hoping to get this into the next release of Pro.

Sorry I cannot help more,

--Rich

0 Kudos
RichRuh
Esri Regular Contributor

I just realized that I never went back and updated this thread.

We added support for mobile geodatabases in Pro 3.0, which shipped in June 2022. Instead of using DatabaseConnectionProperties as shown in Kirk's code, you should use the MobileGeodatabaseConnectionPath class.

--Rich

0 Kudos