0

I am a newbie in bb 10 app development. I am trying to read contact details for this I am able to read first name and last name (any type of single data type value). But in case of QList value I am unable to find value.

Here is my code:

foreach(Contact le, contactList ){

    out << "Name: "<< le.displayName()<<","<<le.firstName()<<" "<<le.lastName()<<"\n";
    out << "No: ";

    const QList<ContactAttribute> noAttributes = le.phoneNumbers();
    foreach (const ContactAttribute &noAttribute, noAttributes) {

        out<< "in";
        out<< noAttribute.value();
    }

    out<<"\n";
}
Radhika
  • 2,453
  • 2
  • 23
  • 28
Eli Moon
  • 73
  • 10

1 Answers1

1

Try this -

    // getting phone numbers
    QVariantMap map_contact;
    QList<ContactAttribute> phoneno_list = contact_info.phoneNumbers();

    if(!phoneno_list.isEmpty())
    {
        foreach(ContactAttribute attr, phoneno_list)
        {
            switch (attr.subKind()) {
                case AttributeSubKind::PhoneMobile:
                    map_contact["phonemobile"] = attr.value();
                    break;
                case AttributeSubKind::Home:
                    map_contact["phonehome"] = attr.value();
                    break;
                case AttributeSubKind::Work:
                    map_contact["phonework"] = attr.value();
                    break;
                default:
                    map_contact["phone"]= attr.value();
                    break;
            }
        }
    }
Kanak Sony
  • 1,570
  • 1
  • 21
  • 37
  • Hi, @Kanak Sony thanks for reply. I try this code but it can't go inside the if case. Means phoneno_list comes an an empty but my device having some contact with numbers on it. – Eli Moon Feb 15 '14 at 07:15