Hi All,
I want to access PIM name field in series 60 3rd FP2 devices.can anybody tell me how should I access it?
I am using 6210 navigator phone.
please help me ASAP...
Thanx
Hi All,
I want to access PIM name field in series 60 3rd FP2 devices.can anybody tell me how should I access it?
I am using 6210 navigator phone.
please help me ASAP...
Thanx
Hi devdattac,
here you will find a complete list of available PIM fields on S60 devices:
http://www.forum.nokia.com/document/...65DD381F0.html
Pit
hi devdattac here is a code for writing and reading contact name and mobile number. in the same way u can add more fields supported by device and can read too.
hope this code will help u.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.Enumeration;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.*;
import javax.microedition.pim.Contact;
import javax.microedition.pim.ContactList;
import javax.microedition.pim.PIM;
import javax.microedition.pim.PIMException;
/**
* @author jitendra
*/
public class pimMidlet extends MIDlet implements CommandListener,Runnable
{
Display dis;
Form form;
List list;
PIM pim;
ContactList clist;
Command cmd_read,cmd_write,cmd_exit;
TextField name_field, number_field;
Thread thread;
public pimMidlet()
{
dis = Display.getDisplay(this);
form = new Form("");
list=new List(null,List.IMPLICIT);
// Open default contact list
pim = PIM.getInstance();
cmd_read = new Command ("Read",Command.SCREEN,1 );
cmd_write = new Command ("Write",Command.SCREEN,1 );
cmd_exit = new Command ( "Exit",Command.EXIT,2);
name_field = new TextField("Enter Name", "", 30, TextField.ANY);
number_field= new TextField("Enter Number", "", 10, TextField.PHONENUMBER);
form.addCommand(cmd_write);
form.addCommand(cmd_read);
form.addCommand(cmd_exit);
form.append(name_field);
form.append(number_field);
form.setCommandListener(this);
try{
clist = (ContactList) pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
}catch (PIMException pe)
{
pe.toString();
}
}
public void startApp()
{
dis.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void readContact()
{
// Retrieve contact values
// The countValues() method returns the number of data values currently
// set in a particular field.
try {
Enumeration contacts = clist.items();
while (contacts.hasMoreElements()) {
Contact c = (Contact) contacts.nextElement();
int phoneNumbers = c.countValues(Contact.TEL);
for (int i = 0; i < phoneNumbers; i++) {
if (c.getAttributes(Contact.TEL, i) != 0 && Contact.ATTR_MOBILE != 0) {
String str = c.getString(Contact.TEL, i);
System.out.println("conact ==="+ str);
String str1=c.getString(Contact.FORMATTED_NAME, i);
list.append(str1+" : "+str,null);
}
}
}
} catch (PIMException pe) {
pe.toString();
System.out.println("errorrrrrrrrr");
}
dis.setCurrent(list);
}
public void addContact()
{
thread = new Thread(this);
thread.start();
}
public void run()
{
String name = name_field.getString().trim();
String number = number_field.getString().trim();
Contact con = clist.createContact();
con.addString(Contact.FORMATTED_NAME, Contact.ATTR_NONE, name);
con.addString(Contact.TEL, Contact.ATTR_MOBILE, number);
try{
con.commit();
}catch(PIMException pe)
{
pe.toString();
System.out.println("errrrrrrorrrrrrrrr");
}
}
public void commandAction(Command command, Displayable displayable)
{
if ( command == cmd_write)
{
if (!name_field.getString().equals("")&& !number_field.getString().equals(""))
addContact();
}
if (command == cmd_read)
readContact();
if (command == cmd_exit)
{
notifyDestroyed();
destroyApp(true);
}
}
}