I'm trying to develop a backup on remote server of PIM details. I wrote an app to read and send contact details of the phone to a remote server via httpconnection. I developed this in sun java WTK 3.0. My app works fine on emulator. Contacts are succesfully transfered and saved to a remote database. But when it is deployed on a mobile devece(Nokia N73, Nokia 6120) , contacts are not transferred succesfully. It is send only one contact. Following is the code i have written;
while (items.hasMoreElements()) {
homeNumber="None";
mobileNumber="None";
faxNumber="None";
Contact contact = (Contact) items.nextElement();
//-------Read data-------------
int telCount = contact.countValues(Contact.TEL);
int nameCount = contact.countValues(Contact.NAME);
if( nameCount>0){
String []names=contact.getStringArray(Contact.NAME, Contact.ATTR_NONE);
contactName = names[contact.NAME_GIVEN];
}else{
contactName="None";
//System.out.println("No name"+ "telcount- "+ telCount +", nameCount"+ nameCount +", Name is" +contact.getString(Contact.FORMATTED_NAME, 0) );
}
if(telCount>0){
for (int i = 0; i < telCount; i++){
int telAttributes = contact.getAttributes(Contact.TEL, i);
if(telAttributes==Contact.ATTR_HOME){
homeNumber=contact.getString(Contact.TEL, i);
}else if(telAttributes==Contact.ATTR_MOBILE){
mobileNumber=contact.getString(Contact.TEL, i);
}else if(telAttributes==Contact.ATTR_FAX){
faxNumber=contact.getString(Contact.TEL, i);
}else{
System.out.println("Have no given type of contact numbers");
}
}
}else{
System.out.println("Have no any type of contact numbers");
}
//--------End of reading-------
System.out.println(contactName +"-->"+mobileNumber);
String oneEntry=contactName +"-->"+mobileNumber;
record=oneEntry;
sb.append(record);
System.out.println("before writing data");
dos.writeUTF(oneEntry);
System.out.println("after writing data");
dos.flush();
}
I'm new to J2ME and appreciate ur feedback.

Reply With Quote

