android - How can I remove a registered geofence? -


i have code should removing registered geofence doesn't seem doing anything.

this code have removing:

constants.landmarks.remove(item); populategeofencelist(); locationservices.geofencingapi.removegeofences(mgoogleapiclient, requestid).setresultcallback(this); addgeofencesbuttonhandler(); 

landmarks hashmap storing string key , latitude , longitude. "item" string should key found in hashmap. requestid arraylist containing item.

the addgeofencesbuttonhandler method make sure remaining geofences registered, don't need call method.

here code populategeofencelist method:

public void populategeofencelist() {     (map.entry<string, latlng> entry : constants.landmarks.entryset()) {         mgeofencelist.add(new geofence.builder()                 .setrequestid(entry.getkey())                 .setcircularregion(                         entry.getvalue().latitude,                         entry.getvalue().longitude,                         constants.geofence_radius_in_meters)                 .setexpirationduration(constants.geofence_expiration_in_milliseconds)                 .settransitiontypes(geofence.geofence_transition_enter | geofence.geofence_transition_exit)                 .build());     } } 

i have sqlite database storing other data. should keeping latitude , longitude in database instead of hashmap?

figured out problem is, needed mgeofencelist.clear() before populategeofencelist()

also don't know if helped made iterator iterate through hashmap make sure key existed before removing it.