Select to view content in your preferred language

Error With Geodatabase Query

835
1
05-11-2021 06:25 AM
zhenghanzhang
Emerging Contributor

dear everyone:

I got an error when i writed the code.I wanted to find features in a geodatabase file.

the error is :

Feature search failed for: asd. Error: com.esri.arcgisruntime.ArcGISRuntimeException: Invalid call.: Object failed to load, unable to execute task.

 

My code is follow the sample :Feature layer query.

https://developers.arcgis.com/android/java/sample-code/feature-layer-query/

 

here is my code:

private void searchForState(final String searchString) {
// clear any previous selections
mFeatureLayer = featureLayerList.get(0);

mFeatureLayer.clearSelection();
// create objects required to do a selection with a query
QueryParameters query = new QueryParameters();
// make search case insensitive

query.setWhereClause("upper(STATE_NAME) LIKE '%" + searchString.toUpperCase() + "%'");

// call select features
final ListenableFuture<FeatureQueryResult> future = mServiceFeatureTable.queryFeaturesAsync(query);

// add done loading listener to fire when the selection returns
future.addDoneListener(() -> {
try {
// call get on the future to get the result
FeatureQueryResult result = future.get();
// check there are some results
Iterator<Feature> resultIterator = result.iterator();
if (resultIterator.hasNext()) {
// get the extent of the first feature in the result to zoom to
Feature feature = resultIterator.next();
Envelope envelope = feature.getGeometry().getExtent();
mMapView.setViewpointGeometryAsync(envelope, 10);
// select the feature
mFeatureLayer.selectFeature(feature);
} else {
Toast.makeText(this, "No states found with name: " + searchString, Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
String error = "Feature search failed for: " + searchString + ". Error: " + e.getMessage();
Toast.makeText(this, error, Toast.LENGTH_LONG).show();
Log.e("zhz search :", error);
}
});
}
0 Kudos
1 Reply
RamaChintapalli
Esri Contributor

Hi,
Since you are working with the Geodatabase file and working with GeodatabaseFeatureTables,  the code for performing query operation on GeodatabaseFeatureTable is same as query on ServiceFeatureTable which you are already following from above sample.

Can you check the LOAD status of theGeodatabaseFeatureTables on which the query is being performed? If the table is LOADED and queryParameter's has a valid whereClause for the table, then we expect it to work as in the sample.

Thanks
Rama

0 Kudos