Skip to content

Deleting object from cache

This method deleted an object from cache if it is present there. All methods are available via Backendless.Cache.[methodname] accessor:

// synchronous method
public void delete( String key )

// asynchronous methods
public void delete( String key, AsyncCallback<Object> callback )


Argument                Description
key identifies the object to delete from cache.
callback the callback used for asynchronous calls to deliver result or fault to the calling program.


AsyncCallback<Object> callback = new AsyncCallback<Object>()
          public void handleResponse( Object result )
             Log.i( "MYAPP", "[ASYNC] object has been deleted from cache" );

          public void handleFault( BackendlessFault backendlessFault )
            Log.e( "MYAPP", "Error - " + backendlessFault.getMessage() );

    // delete object asynchronously
    Backendless.Cache.delete( "firstorder", callback );

    // delete object synchronously
    Backendless.Cache.delete( "firstorder" );
    Log.i( "MYAPP", "[SYNC] object has been deleted from cache" );