Can we read the whole contact list from the MIDlet?
In the emulator i use , there is always two contacts.
MY midlet just read the data I have entered.
YES, you can read all the data that exists in the phone book or the contact list.
And sometime it produces the error if I try to read the fields that was not written by me.
For example, if I write some contact in the contact list (but not name)
if I try to read name, there is an application error?
You can read only the fields that exists and have some valid data stored in them for a particular contact record.
Why? In the real application, there may be many records in the phone book.
And some data will be missing to be filled?
in that condition, will the application error occur?
You would be 1st required to check if the particular field that you are trying to read from a contact is supported by the contact item and exists in it.
For example before reading Contact.NAME field you should do something like this:
Code:
try {
if(list.isSupportedField(Contact.NAME) && contact.countValues(Contact.NAME) > 0)
{
String[] newname = contact.getStringArray(Contact.NAME, 0);
}
}catch(Exception e){}