Search code examples
blackberryfilesystemsbitmapbitmapimage

Assigning image to BitmapField from file system in BlackBerry


In BlackBerry I have a bitmapfield. I want that on the click event of the bitmapfield. The file system in the device should get opened and the user will select an image from the file system and that image will get assigned to the bitmapfield.

I am new to working with such things on a bitmapfield. Would any one please provide me some code or link for doing this?


Solution

  • You need to implement FieldChangeListener with fieldChanged method and set an instance of it via myBitmapField.setChangeListener(...). Here is a reasonable example right in the question.

    Now, inside the fieldChanged(), you need to call a file picker. If you are lucky and you can develop for 5.0 or above, FilePicker is the class you want to use.

    For older BlackBerries there is no file picker, you would need to develop it yourselves. Good news is, you can base it on an existing code from examples, there is File Explorer demo in components\samples\com\rim\samples\device\fileexplorerdemo.