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
msimion
Posts: 11
Registered: ‎02-13-2009
My Device: Not Specified

fileconnection problem on blackberry 8310 os 4.2.2

Hi guys,

 

I have a problem connecting to file:///SDCard/BlackBerry/pictures/user/pictures/IMG00150.jpg on BlackBerry 8310, OS 4.2.2 , from my application. The FileConnection returns always null, although I set all permissions to allow for my application. Camera application saves a picture to that path and I want to read it. If someoane has a clue please help.

 

Thank you,

Simion

Please use plain text.
New Developer
dupuyyann
Posts: 11
Registered: ‎01-21-2009
My Device: Not Specified

Re: fileconnection problem on blackberry 8310 os 4.2.2

After connection you load your inputstream in order to create an encodedimage and then display your image ?

 

Code example

 

FileConnection fconn = (FileConnection)Connector.open(path);
            System.out.println("Connection establish ");
            if (fconn.exists())
            {
                InputStream input = fconn.openInputStream();
                msg+= "inputstrem-";
                msg+= "1-";
                //int available = input.available();
                msg+= "-2-";
                byte[] data ;
                msg+= "-3-";
               
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                int j = 0;
                while((j=input.read())!=-1)
                {
                    baos.write(j);
                }
                data = baos.toByteArray();
                               
                EncodedImage image = EncodedImage.createEncodedImage(data,0,data.length);
                Bitmap b = image.getBitmap();
                BitmapField picture = new BitmapField(b);
                add(picture);
                add(new LabelField("Data Length:" + data.length));
            }
            else
            {
                add(new LabelField("Picture "+path+" doesn't exist msg:"+msg ));
            }

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: fileconnection problem on blackberry 8310 os 4.2.2

Following code allowed me to access just taken phot from my App.

 

FileConnection fileConn = (FileConnection)Connector.open("file:///SDCard/BlackBerry/pictures/IMG00003-20090213-1011.jpg" , Connector.READ);

 

fileConn.exists() this returned me true.

 


Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
New Developer
msimion
Posts: 11
Registered: ‎02-13-2009
My Device: Not Specified

Re: fileconnection problem on blackberry 8310 os 4.2.2

Yes, I wrote the code for loading an InputStream. The problem is that fconn is null. It happens on my phone and not on deviceanywhere's phone, which is the same as mine, only os is diffrent( os 4.5.0). Thank you for the code anyway.
Please use plain text.
New Developer
dupuyyann
Posts: 11
Registered: ‎01-21-2009
My Device: Not Specified

Re: fileconnection problem on blackberry 8310 os 4.2.2

if that works on other phone with firmware 4. that mean may be that functionnality was not implement in firmware 4.2

Check on bb api documentation

Please use plain text.