WEB开发网
开发学院软件开发Java J2ME Personal Information Management (PIM) 概览... 阅读

J2ME Personal Information Management (PIM) 概览

 2010-08-16 00:00:00 来源:WEB开发网   
核心提示: Contact 和 ContactList一个 Contact 表示 Address Book 中的单个条目,Contact 中的主要字段是 Name、Address、Email、Birthday、Photo 和 Telephone,J2ME Personal Information Manag

Contact 和 ContactList

一个 Contact 表示 Address Book 中的单个条目。Contact 中的主要字段是 Name、Address、Email、Birthday、Photo 和 Telephone。

为了确保跨平台可移植性,建议使用 Super Interface PIMList 提供的方法 isSupportedField()。

清单 1 展示如何向 Address Book 添加一个 Contact:

清单 1. 将 Contact 添加到 Address Book

ContactList addressBook = null; 
 try { 
  addressBook = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, 
                                   PIM.READ_WRITE); 
 } catch (PIMException e) { 
  // Exit Application 
 } 
 
 
Contact singleContact = addressBook.createContact(); 
String[] name = new String[addressBook.stringArraySize(Contact.NAME)]; 
 
if (addressBook.isSupportedField(Contact.NAME_FORMATTED) 
 singleContact.addString(Contact.NAME_FORMATTED, 
            PIMItem.ATTR_NONE, "Mrs. Jane Doe"); 
 
 
The createContact() method creates a temporary empty Contact. A commit() call makes 
the Contact data persistent. It is advisable to close the lists by invoking the close() 
 method after necessary operations have been performed. 
 
try { 
   singleContact.commit(); 
 } catch (PIMException e) { 
   // Exception occured 
 } 
 
try { 
// Other cleanup tasks 
   addressBook.close(); 
 } catch (PIMException e) { 
 
 } 
 

上一页  1 2 3 4 5  下一页

Tags:JME Personal Information

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接