×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    4

    Unhappy Can't access/read SIM phonebook in Nokia

    Hi all, am trying to access both the Phone's phonebook and SIM phonenook on Nokia 5130c-2 XpressMusic.
    The app runs without errors but it only returns the numbers from the phone's Phonebook. When I list the available phonebooks using this code
    String[] all_contact_lists=PIM.getInstance().listPIMLists(PIM.CONTACT_LIST);
    it gives me both the Phonebook and SIM card lists. i.e
    1. Phone
    2. SIM

    I have tried explicitly reading from the SIM card using this code but it still returns nothing(even though I have numbers saved in the SIM card.)
    Code:
    ContactList clist = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY,
                        "SIM");
    Here's my complete code::

    Code:
    import javax.microedition.midlet.*;
    import javax.microedition.pim.*;
    import com.sun.lwuit.*;
    import java.util.*;
    
    public class contacts extends MIDlet
    {
        private List my_list=new List();
        private String[] names=null;
        public void startApp()
        {
            Display.init(this);
           Form my_form=new Form("Contacts List");       
           String[] all_contact_lists=PIM.getInstance().listPIMLists(PIM.CONTACT_LIST);
           //Iterate through available phonebooks
           for(int db=0; db<all_contact_lists.length; db++)
           {
            try {
                ContactList clist = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY,
                        all_contact_lists[db]);
                Enumeration contacts=clist.items();
                while(contacts.hasMoreElements())
                {
                    Contact contact=(Contact)contacts.nextElement();
                    try{
                        String phone_contact="";
                        names=contact.getStringArray(Contact.NAME, 0);
                        for(int i=0; i<names.length; i++)
                        {
                            if(names[i]!=null)
                                phone_contact+=" "+names[i];
                        }
                        //my_list.addItem(phone_contact);
                        int phone_numbers=contact.countValues(Contact.TEL);
                        if(phone_numbers>0)
                        {
                             String number=contact.getString(Contact.TEL,0);
                            my_list.addItem(phone_contact+":"+number);
                        }
                        else
                        {
                            my_list.addItem(phone_contact);
                        }
                        //clist.removeContact(contact);
                    }
                    catch (Throwable t) {
                t.printStackTrace();
                }
    
                }
            } catch (PIMException ex) {
                ex.printStackTrace();
            }
           }
           //my_list.addItem(all_contact_lists);
           my_list.setRenderingPrototype("WWWWWWWWWWWWWWWWWWWW");
           my_form.addComponent(my_list);
           my_form.show();
           }
        public void pauseApp(){}
        public void destroyApp(boolean unconditional){}
    
    
    }

  2. #2
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: Can't access/read SIM phonebook in Nokia

    In general Series 40 phones support SIM phonebook, whereas S60 / Symbian devices, do not, so you should be able to do that.

    When you say that you get nothing, do you mean that you can see the other contacts ok, but not the contacts on SIM card?

    I did not find any mistakes in your code during a cursory look, but I did not test the code at all.
    More information about PIM API
    http://library.developer.nokia.com/t...39613197F.html

    Hartti

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    4

    Re: Can't access/read SIM phonebook in Nokia

    Thanks Hartti for the reply. About getting nothing, I get results from the phone's phonebook but no results from the SIM cards phonebook.

  4. #4
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: Can't access/read SIM phonebook in Nokia

    Sorry, but stupid question: And you are certain that there are contacts on the SIM card as well?
    Can you also create a new contact on the SIM card (manually) and see if you can find that contact?

    Hartti

  5. #5
    Registered User
    Join Date
    Sep 2011
    Posts
    4

    Re: Can't access/read SIM phonebook in Nokia

    I have tried explicitly reading from the SIM card using this code but it still returns nothing(even though I have numbers saved in the SIM card.)
    Yes, the SIM card is fine. I can CRUD(Create Remove Update and Delete) contacts from it. And ALL contacts from the SIM card are natively accessible by the phone. Problem is that while my J2ME app CAN get an instance to the SIM phonebook, I don't get results for the stored contacts. Please also keep in mind that no exception is thrown, just that the result is empty.!

  6. #6
    Registered User
    Join Date
    Jul 2007
    Posts
    13

    Re: Can't access/read SIM phonebook in Nokia

    try to print out the value of all_contact_lists[db] after entering the for loop no all_contact_lists.

    It should write the name of the contact list in this device

    How ever I don't read the SIM in samsung, Series 60 and when the device's heapSize is less than 512Kb

    In these cases I use only:
    PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_ONLY)

Similar Threads

  1. Replies: 3
    Last Post: 2010-08-31, 14:46
  2. read Phonebook from all nokia phones
    By showday in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2009-03-17, 09:04
  3. Nokia 6600 Phonebook access?
    By GattusoMatrazzi in forum Symbian C++
    Replies: 15
    Last Post: 2007-08-29, 06:50
  4. Read/delete message/phonebook from nokia API?
    By alicegue in forum Mobile Java General
    Replies: 1
    Last Post: 2006-03-10, 13:37
  5. read write modify phonebook entries of Nokia 6310i
    By tixoman in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2002-12-13, 09:22

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •