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 Developer
nicolas
Posts: 10
Registered: ‎09-14-2008
Accepted Solution

Load a gif file from BlackBerry disk

Hi all,

I would like to download a gif file using HTTP , save it on disk  (as the image will not be updated every time) and load it from disk.

I have found documentation about loading images from a resource but can not find anything about loading a GIF file from the disk.

Is there any documentation about this ?

 

thx 

Please use plain text.
Developer
richard_puckett
Posts: 191
Registered: ‎04-03-2008

Re: Load a gif file from BlackBerry disk

Just need to use FileConnection (JSR75).  Make sure you specify the path to your gif correctly and then open a connection and read it in.  There are many examples on the interwebs on how to do this.
Please use plain text.
Developer
KarlH
Posts: 29
Registered: ‎09-12-2008

Re: Load a gif file from BlackBerry disk

Here's one example I got from another thread on this board last week and it works well; I also found the doc to be cryptic without this example:

 

        MainScreen main = new MainScreen();

        try {
            FileConnection fconn = (FileConnection)Connector.open("file:///store/samples/pictures/Ascension.png");
            // If no exception is thrown, then the URI is valid, but the file may or may not exist.
            if (fconn.exists()) {
                InputStream input = fconn.openInputStream();
                int available = input.available();
                byte[] data = new byte[available];
                input.read(data, 0, available);
                EncodedImage image = EncodedImage.createEncodedImage(data,0,data.length);
                Bitmap b = image.getBitmap();
                BitmapField picture = new BitmapField(b);
                main.add(picture);
                main.add(new LabelField("Data Length:" + data.length));
            }
            else {
                main.add(new LabelField("Picture doesn't exist"));
            }
            fconn.close();
        }
        catch (Exception ioe) {
            main.add(new LabelField("Error"));
        }
        pushScreen(main);
 

Please use plain text.
New Developer
nicolas
Posts: 10
Registered: ‎09-14-2008

Re: Load a gif file from BlackBerry disk

[ Edited ]

Works great.

Great sample.

Thank you.

Hope it wil be added to the documentation.

 

Nicolas

Message Edited by nicolas on 09-17-2008 03:42 PM
Please use plain text.
Developer
KarlH
Posts: 29
Registered: ‎09-12-2008

Re: Load a gif file from BlackBerry disk

In fairness to the original author (if this is the original author) I found it at the BlackBerry Developer Community at blackberry.developercommunity.com written by a poster named Saravanan.
Please use plain text.
Developer
thinakar11
Posts: 31
Registered: ‎01-31-2009

Re: Load a gif file from BlackBerry disk

Can't work with 8703e running 4.1.x version.

The JVM here won't support javax.microedition.io.File interfaces and hence FileConnection is invalid.

Any solutions please.

Do I have to write a JNI to open and read files.

Please use plain text.
Administrator
MSohm
Posts: 14,061
Registered: ‎07-09-2008
My Carrier: Bell

Re: Load a gif file from BlackBerry disk

The FileConnection APIs were added in BlackBerry handheld software version 4.2.0.  There are not available in previous versions.  However, you can upgrade the BlackBerry 8730e to version 4.2.1 or 4.5.0 and make use of these APIs.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
thinakar11
Posts: 31
Registered: ‎01-31-2009

Re: Load a gif file from BlackBerry disk

I need to upgrade it to 4.5. Can you tell me how?  I went to blackberry website: http://na.blackberry.com/eng/services/devices/#tab_tab_update 

and pressed update.  It picked up PIN number from my 8703e device and said my device is up to date with current version.

I know my current version is only 4.2.1.110.  I am trying to upgrade it to 4.5.

 

Thanks.

 

 

Please use plain text.
Administrator
MSohm
Posts: 14,061
Registered: ‎07-09-2008
My Carrier: Bell

Re: Load a gif file from BlackBerry disk

Please contact your carrier to verify the latest version of BlackBerry handheld software they support.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.