Clicky

How to retrieve ALL image from picture folder ?

I am develop an application about send an email with attachment all image from picture folder.
when the user click on Compose Email, it will link to compose email, all the adress and subject are default. Those i done already, i only left one thing dunno how to retrieve all the image from the picture folder....  Hope someone can help me... please to show me the sample code, coz i totally new in JAVA. and the application is BlackBerry.
The path for the picture is -->    /Device Memory/home/user/pictures/
i will show u the screen and the coding
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
package com.rim.samples.device.sendmediademo;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.blackberry.api.invoke.*;
import net.rim.blackberry.api.mail.*;

public class Lesson2Screen extends MainScreen { 
    //create a button to send of the mail
    ButtonField btnSend = new ButtonField("Send eMail", ButtonField.CONSUME_CLICK){
        protected boolean navigationClick( int status, int time ){
            sendMail(eTo.getText(),eSubject.getText(),eBody.getText(),eAttachment.getText());
            return true;
        }
    };    
    
    //ordinal - Ordering parameter, lower values are placed closer to the top of the menu screen.
    //priority - The priority of the menu item. A lower value indicates a higher priority, conversely a higher value indicates a lower priority.
    MenuItem myMenu = new MenuItem("My Menu!", 1/*ordinal*/, 100/*priority*/) {
        public void run() {
            Dialog.alert("You clicked on my Menu!");
        }
    };
    
    //this creates a colored label
    LabelField topLabel = new LabelField("** Hello World **", LabelField.FIELD_HCENTER){
        public void paint(Graphics graphics){
            //you can set the color here
            graphics.setColor(0x00AA0099);
            super.paint(graphics);
        }
    }; 
    
    EditField eTo = new EditField("To:testing@hello.com","");
    EditField eSubject = new EditField("Subject:only for testing","");
    EditField eBody = new EditField("Body:testing 123","");
    EditField eAttachment = new EditField("Attachment:","");
    public Lesson2Screen() {
        super();
        LabelField title = new LabelField("Create eMail messages");
        //set the title of the application
        setTitle(title);
        
        add(topLabel); //adds the colored label here on top of the other fields
        add(new SeparatorField());
        
        add(eTo); //adds the address field to the screen
        add(eSubject); //the editfield for the subject line
        add(eBody); //edit field for the body
        add(eAttachment); //for attachment
        //a separator item; long, thin, horizontal line from the left to the right of the screen
        add(new SeparatorField());
        
        addMenuItem(myMenu); //adds the menu to the screen
        add(btnSend);
    }
   
        public void sendMail(String to, String subject, String body, String Attachment){
                        try {
                    // set dst folder
                    Store store = Session.getDefaultInstance().getStore();
                    Folder[] folders = store.list(Folder.SENT);
                    Folder sentfolder = folders[0];
                    
                    // create a new message
                    Message msg = new Message(sentfolder);
                    
                    // make adressed
                    Address toList[] = new Address[1];
                    toList[0]= new Address(to, to);
                    msg.addRecipients(Message.RecipientType.TO, toList);
                    
                    // make message
                    msg.setSubject(subject);
                    msg.setContent(body);
                    msg.setContent(Attachment);
                    Transport.send(msg); // send it off
                    } catch(Exception e){}
        }
        
    //...when this screen closes, onClose() will be run
    public boolean onClose() {
        //force the app to quit
        System.exit(0);
        return true;
    }  
}
pic1.jpg (169 KB)
capture screen (image/jpeg)

asked 10/12/2010 10:33

ryanW's gravatar image

ryanW ♦♦


4 Answers:
you can get all the files in a particular directory,
http://www.java-tips.org/java-se-tips/java.io/list-the-names-of-all-files-in-a-particular-dire.html
http://www.exampledepot.com/egs/java.io/TraverseTree.html
http://www.javafaq.nu/java-example-code-120.html

Then you can filter out those names, which are not image files.

Assuming that you  have the logic for a single file, it can be applied for the list of files derived from above logic

link
gurvinder372's gravatar image

gurvinder372

i need to retrieve all the image from the folder not only the file name....
do u have this simple code which suitable for the code that i show?
i am urgent to donw this by today.... hopefully can have the solution.
i have no time to figure out anymore... my boss is chasing on this..!!!
link
ryanW's gravatar image

ryanW

article with related solution
link
ryanW's gravatar image

ryanW

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

Asked: 10/12/2010 10:33

Seen: 255 times

Last updated: 10/14/2010 05:00