0

I am developing a blackberry application where i want to select an image present in device and display it in my application. How to do it.

UPDATE

hi I used FilePicker to get the path of the file and i am storing it in "Selection(String)" and i am using below code to display image in my application but i am getting exception. can anybody tell me where i did mistake.

try {
            FileConnection fconn = (FileConnection)Connector.open(selection,Connector.READ);
            // 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);
                add(picture);
                add(new LabelField("Data Length:" + data.length));
            }
            else {
                add(new LabelField("Picture does not exist"));
            }
            fconn.close();
        }
        catch (Exception ioe) {
           add(new LabelField("Error"));
        }
chaitu2408
  • 97
  • 5
  • This could probably be useful: http://stackoverflow.com/questions/7991716/how-can-i-get-filepicker-working-properly-on-certain-blackberry-handsets – Vit Khudenko Nov 29 '11 at 17:44

1 Answers1

1

If your target OS is 6.0+ you can use RIM component FilePicker. For lower OS versions you can use also this component: File Selection Popup

Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114