public void delete ( final String whereClause , final String [ ] whereArgs , final SuccessCallback < Integer > successCallback , final ErrorCallback errorCallback ) { checkNotNull ( successCallback ) ; checkNotNull ( errorCallback ) ; final Callable < Integer > call = new Callable < Integer > ( ) { @ Override public Integer call ( ) throws Exception { return SugarRecord . deleteAll ( getSugarClass ( ) , whereClause , whereArgs ) ; } } ; final Future < Integer > future = doInBackground ( call ) ; Integer count ; try { count = future . get ( ) ; if ( null == count ) { errorCallback . onError ( new Exception ( "Error when performing delete of all elements" ) ) ; } else { successCallback . onSuccess ( count ) ; } } catch ( Exception e ) { errorCallback . onError ( e ) ; } }
Method that performs a selective delete . The code is executed asynchronously via the usage of Futures and result callbacks