BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 11-16-2007, 08:13 AM   #1 (permalink)
New Member
 
Join Date: Nov 2007
Model: 8800
PIN: N/A
Carrier: Rogers
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Why can't we do this for deleting SMS?

Please Login to Remove!

Hello,

I am awaiting my signing key to test this, but would this not work for deleting certain SMS messages... For example, I have an app that listens for all SMS messages... Ones from "JOE" will trigger me to do something and then I'd like to delete those messages... All others leave alone. So why can't I do the following:
Code:
Store store = Session.getDefaultInstance().getStore();
Folder[] folders = store.list(Folder.INBOX);
Folder inbox = folders[0];
Message[] msgs = inbox.getMessages();
for( int i = 0; i < msgs.length; i++ ){
    if( msgs[i].getFrom().getAddr().equals("JOE") ){
        inbox.deleteMessage( msgs[i] );
        break;
    }
}
Is there something I am missing, or shouldn't that work?

Last edited by dfound : 11-16-2007 at 08:15 AM. Reason: cleaned up source code
Offline  
Old 11-16-2007, 11:47 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
richard.puckett's Avatar
 
Join Date: Oct 2007
Location: Seattle, WA
Model: 9020
PIN: N/A
Carrier: T-Mobile
Posts: 212
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You'll need to wait until you can sign your app, otherwise you should receive a ControlledAccessException since you're using controlled APIs.

Your code works fine on my hardware after I signed it, BTW.
Offline  
Old 11-16-2007, 01:21 PM   #3 (permalink)
New Member
 
Join Date: Nov 2007
Model: 8800
PIN: N/A
Carrier: Rogers
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got my signing key, but when I get the "Inbox" folder, and perform a getMessages(), the size is zero. Is this why we can't delete messages? Can we not even read messages in the inbox?
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Allen Bradley 1747-M13 Ser A SLC 500 Memory Module 1747M13
$54.99
Allen Bradley 1747-M13 Ser A SLC 500 Memory Module 1747M13  picture12x Samsung 8GB 2Rx4 PC3-10600R REG ECC - 240-pin Server Memory M393B1K70CH0 ~
$3.27
12x  Samsung 8GB 2Rx4 PC3-10600R REG ECC - 240-pin Server Memory M393B1K70CH0 ~ picture4x Samsung 8GB 2Rx4 PC3-10600R REG ECC - 240-pin Server Memory M393B1K70CH0 QTY~
$99.79
4x Samsung 8GB 2Rx4 PC3-10600R REG ECC - 240-pin Server Memory M393B1K70CH0 QTY~ pictureNEW, MITSUBISHI, Q2MEM-1MBS, MEMORY CARD, SRAM, 1MB, (4E-4)
$319.99
NEW, MITSUBISHI, Q2MEM-1MBS, MEMORY CARD, SRAM, 1MB, (4E-4) pictureSiemens 6ES5 095-8MA04 CPU Module DC24V & 6ES5 375-1LA21 Memory Module Warranty
$479.99
Siemens 6ES5 095-8MA04 CPU Module DC24V & 6ES5 375-1LA21 Memory Module Warranty picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.