Kinjal Shah
Kinjal Shah

Reputation: 536

How to get list of image files from particular path in Blackberry?

I am new in Blackberry. I want to get all images from particular path like "file:///SDCard/BlackBerry/pictures/". I have searched and found following code..

public static byte[] getBytesFromFile(String filename) throws IOException {
    FileConnection fconn = null;
    InputStream is = null;
    try {
        fconn = (FileConnection) Connector.open(filename, Connector.READ);
        is = fconn.openInputStream();

        return IOUtilities.streamToBytes(is);
    } finally {
        if (is != null) {
            is.close();
        }
        if (fconn != null) {
            fconn.close();
        }
    }
}

I have implemented this but i am getting Not a file exception. Is there any other way ?

If any one has idea, please help me as soon as possible..

Upvotes: 1

Views: 97

Answers (1)

Peter Strange
Peter Strange

Reputation: 2650

Since you are new to Blackberry, I recommend that you review the BlackBerry micro-site for the Java developer, which you will find here:

BB Java Developer Microsite

Included on that page, there are links to various things, included the API documentation, which you will find (for OS 7.1) here:

API Doc for OS 7.1

You are using the FileConnection API, so look for the FileConnection class and see what methods are available - I think the one you want is list().

Finally you might find this sample code, that searches through a directory, useful:

Create-a-file-selection-popup-screen

Good luck.

Upvotes: 2

Related Questions