Help Center

Local Navigation

Create a collection listener to notify the system when a collection changes

The system invokes CollectionEventSource.addCollectionListener() to create a CollectionListener for each SyncCollection the BlackBerry® device application makes available for wireless backup.
  1. Import the net.rim.device.api.util.ListenerUtilities class.
  2. Import the following interfaces:
    • java.util.Vector
    • net.rim.device.api.collection.CollectionEventSource
    • net.rim.device.api.collection.CollectionListener
    • net.rim.device.api.synchronization.SyncCollection
  3. Create a private vector object to store the collection of SyncCollection listeners for the BlackBerry device application.
    private Vector _listeners; 
    _listeners = new CloneableVector();
    
  4. Implement the CollectionEventSource.addCollectionListener() method, making sure the method adds a CollectionListener to the Vector that contains listeners. In the following code sample, we implement CollectionEventSource.addCollectionListener() to invoke ListenerUtilities.fastAddListener() to add a listener to theVector that contains listeners.
    public void addCollectionListener(Object listener)
    {
    _listeners = ListenerUtilities.fastAddListener( _listeners, listener );
    }
    

Index


Was this information helpful? Send us your comments.