Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
loffenauer
Posts: 9
Registered: ‎08-03-2010
My Device: 9000
My Carrier: Vodafone
Accepted Solution

Cannot list messages from INBOX

Hi -

 

we are trying to process messages from the Messaging applications INBOX. While we succeed in getting to new messages arriving on the phone after our app was started, we have trouble getting to the messages that arrived before.

 

We try to get to those messages using this snippet of code

 

 

 

// retrieve the default message service
Store store = Session.getDefaultInstance().getStore();
// add the listener
store.addFolderListener(this);
Folder inbox = store.getFolder(Folder.INBOX);
if (inbox != null) {
haveInbox = true;
m = inbox.getMessages();
} else {
haveInbox = false;
m = null;
}

 

// retrieve the default message service

 Store store = Session.getDefaultInstance().getStore(); 

 // add the listener

 store.addFolderListener(this); // works great

// now we fail...
Folder inbox = store.getFolder(Folder.INBOX);

Messages[] m;

if (inbox != null) {

 haveInbox = true;

m = inbox.getMessages();

 } else {

 haveInbox = false;

 m = null;

 }

 

The problem is that store.getFolder(Folder.INBOX) always returns null

 

Anything we do wrong here ?

 

Thanks for your help

 

Please use plain text.
New Contributor
loffenauer
Posts: 9
Registered: ‎08-03-2010
My Device: 9000
My Carrier: Vodafone

Re: Cannot list messages from INBOX

We found the bug. Use

 

Folder[] f = store.list(Folder.INBOX);

 

and iterate over inboxes instead of using

 

store.get(Folder.INBOX), which does not result in anything.

 

Please use plain text.