Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8225001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:15:53+00:00 2026-06-07T15:15:53+00:00

Please anybody let me know how to work with this code, I want to

  • 0

Please anybody let me know how to work with this code, I want to display the Contact Photo on screen. getting null from getPhoto() method. I searched a lot but got nothing apart from this code from Contact Interface. but its not working for me…..!!!

    public class PhotoExample {

    private Contact _contact;

    public PhotoExample(Contact contact) throws PIMException {
        ContactList contactList = (ContactList) 
            PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
        _contact = contactList.createContact();
        /*_contact = contact;*/
    }

    public void setPhoto() throws IOException {
        byte[] photo = getSamplePhoto();
        byte[] photoEncoded = Base64OutputStream.encode(photo, 0, photo.length, false, false);
        if (_contact.countValues(Contact.PHOTO) > 0) {
            _contact.setBinary(Contact.PHOTO, 0, PIMItem.ATTR_NONE, photoEncoded, 0, photo.length);
        } else {
            _contact.addBinary(Contact.PHOTO, PIMItem.ATTR_NONE, photoEncoded, 0, photo.length);
        }
    }

    public byte[] getPhoto() throws IOException {
        if (_contact.countValues(Contact.PHOTO) > 0) {
            byte[] photoEncoded = _contact.getBinary(Contact.PHOTO, 0);
            return Base64InputStream.decode(photoEncoded, 0, photoEncoded.length);
        } else {
            return null;
        }
    }

    private static byte[] getSamplePhoto() {
        return null;
        // return the raw bytes of the photo to use
    }

    /*public static void main(String[] args) throws Throwable {
        PhotoExample example = new PhotoExample();
        example.setPhoto();
        example.getPhoto();
    }*/

}

I am using the above code like this: –

try {
            _photo = new PhotoExample(_contact);
             b = _photo.getPhoto();
        } catch (PIMException e) {
            System.out.println(e+"===>");
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println(e+"===>");
            e.printStackTrace();
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:15:57+00:00Added an answer on June 7, 2026 at 3:15 pm

    After a long time , I tried this task again after a few searching, now i got success and want to share as this code may be useful for many.

    BlackBerryContactList contactList = (BlackBerryContactList)BlackBerryPIM.getInstance().openPIMList(BlackBerryPIM.CONTACT_LIST, BlackBerryPIM.READ_WRITE);
                Enumeration contactListItems = contactList.items();
                while (contactListItems.hasMoreElements()) {
                    BlackBerryContact contact = (BlackBerryContact)contactListItems.nextElement();
                    byte[] imageBytesBase64 = contact.getBinary(BlackBerryContact.PHOTO, 0);
                    byte[] imageBytes = null;
                    try {
                        imageBytes = Base64InputStream.decode(imageBytesBase64, 0, imageBytesBase64.length);
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    EncodedImage encodedImage = EncodedImage.createEncodedImage(imageBytes, 0, imageBytes.length);
                    Bitmap bitmap = encodedImage.getBitmap();
                    bitmaps.addElement(bitmap);
                    BitmapField fd= new BitmapField(bitmap, Field.FIELD_HCENTER);
                    add(fd); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anybody got Django-SocialAuth working with Django-nonrel? Do they work together? Please let me know
Can anybody please let me know that where do the trace flag results get
Please let me know if this has been asked before, I wasn't able to
Can anybody please, let me know that how can we disable a login in
Could anybody please let me know under which cases LDAP would be prefered rather
Can anybody please tell me why the removeEventListener call is not working? this.addEventListener(Event.ENTER_FRAME, eventCall,
Can anybody please help me with this as I have no idea why public
Anybody please give some useful links on this topic.i need to create a content
Can anybody please spot my error, this should be a legal query in SQL
I want to distribute the installer package to my clients. Please anybody provide me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.