hello Pit,
The class that I insert the contact in the phone book I found on the Internet .. this gives me only a few problems with the device (n70, 6234).
The class is as follows, of course adapted to my problem:
Code:
public class PIMImpl extends Thread
{
static Alert check;
StringItem si;
//----------------------------------------Phone Book---------------------------------
int noOfRecords;
public static boolean pimTemp = false;
Random randPh = new Random();
public PIMImpl()
{
}
public void run()
{
writeData();
}
public synchronized void writeData()
{
/*String ph[] = new String[PIMWrite.names.length];
for (int i=0;i<PIMWrite.names.length ;i++ )
{
String r = Long.toString(randPh.nextLong());
if(r.startsWith("-"))
{
r = r.replace('-','9');
}
ph[i] =(r.length()>10)?(r.substring(0,10)):(r);
// System.out.println(" PH :"+ph[i] +"i:"+i);
}*/
int tc = 0;
PIM pim;
try{
ContactList contacts = null;
ContactList conT = null;
pim = PIM.getInstance();
try {
contacts = (ContactList) pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
} catch (PIMException e) {
// An error occurred
return;
}
//for(int i=0;i<RiepilogoEspositori.m.length;i++)
//{
Contact contact = contacts.createContact();
String[] name = new String[contacts.stringArraySize(Contact.NAME)];
String[] ind = new String[contacts.stringArraySize(Contact.ADDR)];
// System.out.println("i = "+i);
if (contacts.isSupportedField(Contact.TEL))
{
contact.addString(Contact.TEL, Contact.ATTR_NONE, RiepilogoEspositori.D);
}
if (contacts.isSupportedField(Contact.TEL))
{
contact.addString(Contact.TEL, Contact.ATTR_FAX, RiepilogoEspositori.ora);
}
if (contacts.isSupportedArrayElement(Contact.NAME, Contact.NAME_GIVEN))
name[Contact.NAME_GIVEN] = RiepilogoEspositori.titolo;
contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, name);
if (contacts.isSupportedArrayElement(Contact.ADDR, Contact.ADDR_STREET))
ind[Contact.ADDR_STREET] = RiepilogoEspositori.contenuto;
contact.addStringArray(Contact.ADDR, PIMItem.ATTR_NONE, ind);
if(contacts.isSupportedField(Contact.EMAIL)){
contact.addString(Contact.EMAIL, Contact.ATTR_NONE, RiepilogoEspositori.oraI);
}
try {
contact.commit();
} catch (PIMException e) {
// An error occured
}
//PIMWrite.result.deleteAll();
//String msg=" Contacts Adding :"+i;
//si = new StringItem("",msg);
//PIMWrite.result.append(si);
//}
check = new Alert("Added","Added ",null,AlertType.CONFIRMATION);
check.setTimeout(Alert.FOREVER);
//RiepilogoEspositori.class.display.setCurrent(check);
try {
contacts.close();
} catch (PIMException e) {
}
}catch(Exception e){
String er = e+" ; tc="+tc;
check = new Alert( "Response",er,null,AlertType.CONFIRMATION );
check.setTimeout(Alert.FOREVER);
//PIMWrite.display.setCurrent(check);
}
// return true;
}
}
While the inclusion of events on the calendar, I managed all the exceptions, I only have problems on nokia n70.
chia_84