I'm trying to add a new feature into an existing GeodatabaseFeatureTable but I get the following error when createFeature is called:
com.esri.arcgisruntime.ArcGISRuntimeException: Cannot call this method in this context
Here is the code:
// create a new Geodatabase from local path mGeodatabase = new Geodatabase(mGeoDb); // load the geodatabase mGeodatabase.loadAsync(); // add feature layer from geodatabase to the ArcGISMap mGeodatabase.addDoneLoadingListener(new Runnable() { @Override public void run() { for (GeodatabaseFeatureTable geoDbTable : mGeodatabase.getGeodatabaseFeatureTables()){ java.util.Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("COD", "SIG"); Point gps = new Point(-1.640235, 48.127568, SpatialReferences.getWgs84()); Feature addedFeature = geoDbTable.createFeature(attributes, gps); } }
Any help would be appreciated.
My assumption is that it is probably not fully loaded yet (need to check with that team). If you put this in at a different time, say after another button click, does it get inserted correctly?
I tried to put the following code in an onClick method long after loading features, but the feature doesn't appear. Do I need to use a SyncGeodatabaseTask? If that is the case, I have no clue how to code it...
java.util.Map<String, Object> attributes2 = new HashMap<String, Object>(); attributes2.put("COD", "SIG"); // Coded Values: [0: No] , [1: Yes] Point gps = new Point(-1.640235, 48.127568, SpatialReferences.getWgs84()); Feature addedFeature = mGeodatabase.getGeodatabaseFeatureTable("CARTO_ETARE").createFeature(attributes2, gps); final ListenableFuture<Void> addFeatureFuture = mGeodatabase.getGeodatabaseFeatureTable("CARTO_ETARE").addFeatureAsync(addedFeature); addFeatureFuture.addDoneListener(new Runnable() { @Override public void run() { } });