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.
- Import the net.rim.device.api.util.ListenerUtilities
class.
- 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
- Create a private vector object to store the collection of SyncCollection listeners for the BlackBerry device application.
private Vector _listeners;
_listeners = new CloneableVector();
- 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 the Vector that contains listeners.
public void addCollectionListener(Object listener)
{
_listeners = ListenerUtilities.fastAddListener( _listeners, listener );
}
Index
Was this information helpful? Send us your comments.