Help Center
Local Navigation
- Integrating with BlackBerry Device Software applications
- Unified search
- Device interaction support
- Message list
- Custom messages
- Using custom messages and folders in the message list
- Creating a module for background processes
- Creating a module for the UI
- Create a module for background processes
- Start the module for background processes or the module for the UI
- Create an icon for a custom message
- Create a custom folder in the message list
- Send a notification when a custom folder changes
- Create a custom indicator
- Hide an indicator
- Remove a custom indicator
- Attachments
- Calendar
- Contact list
- Task list
- Phone
- BlackBerry Browser
- Menu items
- Find more information
- Glossary
- Provide feedback
- Document revision history
- Legal notice
BlackBerry Manuals & Help
>
Developer Documentation
>
Java Development Guides and API Reference
>
Development Guide
Integration - BlackBerry Java SDK - 6.0
Create a custom folder in the message list
Custom messages are maintained in custom folders. To perform operations on custom messages, your BlackBerry® device application must register at least one custom folder.
-
Import the required classes and interfaces.
import net.rim.blackberry.api.messagelist.*; import net.rim.device.api.collection.ReadableList;
-
Create a class that implements the
ApplicationMessage interface.
public class MLSampleMessage implements ApplicationMessage
-
Obtain a reference to an
ApplicationMessageFolderRegistry object.
ApplicationMessageFolderRegistry reg = ApplicationMessageFolderRegistry.getInstance();
-
Invoke
ApplicationMessageFolderRegistry.registerFolder() to
register a custom folder for each collection of messages.
// collections of MLSampleMessage instances ReadableList inboxMessages = messages.getInboxMessages(); ReadableList deletedMessages = messages.getDeletedMessages(); ApplicationMessageFolder inboxFolder = reg.registerFolder( INBOX_FOLDER_ID, "Inbox", inboxMessages ); ApplicationMessageFolder deletedFolder = reg.registerFolder( DELETED_FOLDER_ID, "Deleted Messages", deletedMessages, false );
-
Invoke
ApplicationMessageFolder.addListener() to add a
listener so that your application can be notified when specific folder events
occur. In the following code sample, the application listens for deleted
messages. For a list of all actions that you can listen for, see the
documentation for the
ApplicationMessageFolderListener class in the
API
reference for the
BlackBerry® Java® SDK.
deletedFolder.addListener( this, ApplicationMessageFolderListener.MESSAGE_DELETED );
-
Create a class that implements the
ApplicationMessageFolderListener interface.
public class AppFolderListener implements ApplicationMessageFolderListener
-
Implement
ApplicationMessageFolderListener.actionPerformed()
to perform actions when a folder event occurs.
public void actionPerformed( int action, ApplicationMessage[] messages, ApplicationMessageFolder folder ) { // check if action was performed on multiple messages if( messages.length == 1 ) { switch( action ) { case ApplicationMessageFolderListener.MESSAGE_DELETED: messageStore.deleteInboxMessage( message ); ... -
Invoke
ApplicationMessageFolderRegistry.setRootFolderName()
to specify the name of the root folder for your application's custom folders.
The name of the root folder appears in the View Folder dialog box of the
Messages application when an application registers more than one application
message folder.
reg.setRootFolderName( "ML Sample" );
Next topic: Send a notification when a custom folder changes
Previous topic: Create an icon for a custom message