Notify the Unified Search Service about changes to your data

When your application changes, deletes, or creates new searchable data, you can notify the Unified Search Service about the changes by using the AppContentManager object.
Before you begin: Retrieve a registration token to communicate with the Unified Search Service. An application retrieves a registration token when it registers an EntityBasedSearchable object.

Define a variable (such as _myListener in the following code sample) for an AppContentListener implementation. For more information, see "Listening for responses from the Unified Search Service".

  1. Import the required classes and interfaces.
    import net.rim.device.api.unifiedsearch.content.AppContentManager;
  2. To update a SearchableEntity object that the Unified Search Service has already indexed, invoke updateContent().
    public void updateUSS(MyEntity entity, RegistrationToken regToken) {
        MyEntity[] toUpdate = new MyEntity[1];
        toUpdate[0] = entity;
        AppContentManager.getInstance().updateContent(toUpdate, _myListener, regToken);
    }
  3. To delete a SearchableEntity object, invoke deleteContent().
    public void deleteUSS(MyEntity entity, RegistrationToken regToken) {
        MyEntity[] toDelete = new MyEntity[1];
        toDelete[0] = entity;
        AppContentManager.getInstance().deleteContent(toDelete, _myListener, regToken);
    }
  4. To insert a new SearchableEntity, invoke the insertContent() method.
    public void insertUSS(MyEntity entity, RegistrationToken regToken) {
        MyEntity[] toInsert = new MyEntity[1];
        toInsert[0] = entity;
        AppContentManager.getInstance().insertContent(toInsert, _myListener, regToken);
    }

Was this information helpful? Send us your comments.