public void deleteRule(long ruleID){
  if (isClosed) {
    throw new IllegalStateException(TAG + " is closed.");
  }
  ruleDbAdapter.delete(ruleID);
  Cursor cursorRuleAction=ruleActionDbAdapter.fetchAll(ruleID,null);
  while (cursorRuleAction.moveToNext()) {
    long ruleActionID=getLongFromCursor(cursorRuleAction,RuleActionDbAdapter.KEY_RULEACTIONID);
    ruleActionDbAdapter.delete(ruleActionID);
    Cursor cursorRuleActionParameter=ruleActionParameterDbAdapter.fetchAll(ruleActionID,null,null);
    while (cursorRuleActionParameter.moveToNext()) {
      long ruleActionParameterID=getLongFromCursor(cursorRuleActionParameter,RuleActionParameterDbAdapter.KEY_RULEACTIONPARAMETERID);
      ruleActionParameterDbAdapter.delete(ruleActionParameterID);
    }
    cursorRuleActionParameter.close();
  }
  cursorRuleAction.close();
  Cursor cursorFilter=ruleFilterDbAdapter.fetchAll(ruleID,null,null,null,null,null);
  while (cursorFilter.moveToNext()) {
    long ruleFilterID=getLongFromCursor(cursorFilter,RuleFilterDbAdapter.KEY_RULEFILTERID);
    ruleFilterDbAdapter.delete(ruleFilterID);
  }
  cursorFilter.close();
}

public void deleteRule ( long ruleID ) { if ( isClosed ) { throw new IllegalStateException ( TAG + " is closed." ) ; } ruleDbAdapter . delete ( ruleID ) ; Cursor cursorRuleAction = ruleActionDbAdapter . fetchAll ( ruleID , null ) ; while ( cursorRuleAction . moveToNext ( ) ) { long ruleActionID = getLongFromCursor ( cursorRuleAction , RuleActionDbAdapter . KEY_RULEACTIONID ) ; ruleActionDbAdapter . delete ( ruleActionID ) ; Cursor cursorRuleActionParameter = ruleActionParameterDbAdapter . fetchAll ( ruleActionID , null , null ) ; while ( cursorRuleActionParameter . moveToNext ( ) ) { long ruleActionParameterID = getLongFromCursor ( cursorRuleActionParameter , RuleActionParameterDbAdapter . KEY_RULEACTIONPARAMETERID ) ; ruleActionParameterDbAdapter . delete ( ruleActionParameterID ) ; } cursorRuleActionParameter . close ( ) ; } cursorRuleAction . close ( ) ; Cursor cursorFilter = ruleFilterDbAdapter . fetchAll ( ruleID , null , null , null , null , null ) ; while ( cursorFilter . moveToNext ( ) ) { long ruleFilterID = getLongFromCursor ( cursorFilter , RuleFilterDbAdapter . KEY_RULEFILTERID ) ; ruleFilterDbAdapter . delete ( ruleFilterID ) ; } cursorFilter . close ( ) ; }
delete a rule record as well as ruleaction , ruleactionparameter and rulefilters records associated with it .
