How to get Coded Values from Coded Value Domain in Android Runtime SDK 100.0.0

2472
0
05-01-2017 08:25 AM
Labels (1)

How to get Coded Values from Coded Value Domain in Android Runtime SDK 100.0.0

Sometimes users require getting the coded values of the field in Android Runtime. It is a little complicated to get to the Coded domain from the geodatabase. 

Following is an example code to get it. This is for offline geodatabase(Runtime Content), same can be done for geodatabase coming from Service using ServiceFeatureTable class.

//Open the geodatabase file
String path = "/storage/emulated/0/testdomainclass.geodatabase"; // path to the offline runtime content on android device
geodatabase = null;
geodatabase = new Geodatabase(path);
geodatabase.loadAsync();

// add feature layer from geodatabase to the ArcGISMap
geodatabaseFeatureTable = geodatabase.getGeodatabaseFeatureTable("points"); // name of the feature class insife the runtime content
geodatabaseFeatureTable.loadAsync();

Field field = geodatabaseFeatureTable.getField("name"); // name of the field for which the domain is created

Domain domain = field.getDomain();
CodedValueDomain codedValueDomain = ((CodedValueDomain) domain);
List<CodedValue> codedvaluelist = codedValueDomain.getCodedValues();‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

In the above example, codedvaluelist object will contain the name and the code which can be retrieved using following code:

codedvaluelist.get(0).getName(); //name of codedvalue at 0 index
codedvaluelist.get(0).getCode(); // code of codedvalue at 0 index‍‍
Labels (1)
Version history
Last update:
‎12-12-2021 03:44 AM
Updated by: