BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 11-16-2007, 09: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 09:15 AM. Reason: cleaned up source code
Offline  
Old 11-16-2007, 12:47 PM   #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, 02: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

OEM CPU FAN & HEATSINK 14R0011 TSQC0039003--IBM SURE POS 4840-563 TOUCH SCREEN
$3.99
OEM CPU FAN & HEATSINK 14R0011 TSQC0039003--IBM SURE POS 4840-563 TOUCH SCREEN pictureTwo Ribbons & 1 Lift-off tapes 1 IBM Genuine OEM Wheelwriter Typewriter 1380999
$58.87
Two Ribbons & 1 Lift-off tapes 1 IBM Genuine OEM Wheelwriter Typewriter 1380999 pictureOEM IBM SurePOS 700 4800-743/783 250W Power Supply DPS-250AB-45A 46N1999 46N1998
$27.0
OEM IBM SurePOS 700 4800-743/783 250W Power Supply DPS-250AB-45A 46N1999 46N1998 pictureOEM IBM Wheelwriter 5 Part: Paper Release Lever & Bellcrank
$1.99
OEM  IBM  Wheelwriter 5 Part:  Paper Release Lever & Bellcrank pictureGenuine OEM IBM Cartridge Wheelwriter Printwheel Script 12 #1353778
$24.95
Genuine OEM IBM Cartridge Wheelwriter Printwheel Script 12 #1353778 picture






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