In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to understand the concept of J2ME PIM, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Here to share the concept of J2ME PIM, according to the definition of JSR75, Personal Information Management (PIM) API provides a way to access local personal data on mobile devices, including Contacts data, Tasks data, Appointments data and so on.
Introduction to J2ME PIM
According to the definition of JSR75, Personal Information Management (PIM) API provides a way to access local personal data on mobile devices, including Contacts data, Tasks data, Appointments data, and so on. In this article, we will take a closer look at this API, discuss the development, security, and deployment of PIM MIDlet, and compare PIM with another J2MEAPI--RecordManagementStore (RMS).
Personal Information Management (PIM) in Mobile Environment
With the continuous introduction of new devices, the provision of AddressBook, Calendar and TaskList on mobile devices has become an inevitable requirement. J2ME applications also need to access this data. The optional package JSR75 Personal Information Management (PIM) provides this functionality.
It allows access not only to local personal information containing contacts, appointments, and tasks, but also to information based on SIM cards and Local and Remote Personal Information databases attached to the device.
The PIM package supports importing and exporting data from vCard and vCalendar, which are the Internet standard formats for AddressBook and Calendar, respectively. It also has security features that prevent unauthorized classes from retrieving personal information.
Another optional package, JSR75 File Connection, provides a way to access local file systems that are outside the scope of this article.
J2ME PIM package
The Java PIM package is represented by the javax.microedition.pim package.
Important interfaces defined by this package include:
The interface Contact-- represents a single contact on the AddressBook.
The interface ContactList-- represents AddressBook, which is a list of Contact.
The interface Event-- represents a single CalendarEvent.
The interface EventList-- represents a list of Calendar events.
The interface ToDo-- represents a single Task in TaskList.
The interface ToDoList-- represents a list of Task.
The main classes defined by this package are:
The PIM--PIM class defines methods for creating an index of all existing lists, opening and editing those lists as imports or exports from vCard and vCalendar (the Internet standard for Contact and Calendar).
Contact and ContactList
A Contact represents a single entry in the AddressBook. The main fields in Contact are Name, Address, Email, Birthday, Photo, and Telephone.
To ensure cross-platform portability, it is recommended to use the method isSupportedField () provided by SuperInterfacePIMList.
Listing 1 shows how to add a Contact to AddressBook:
Listing 1. Add Contact to AddressBook
ContactListaddressBook=null; try {addressBook= (ContactList) PIM.getInstance (). OpenPIMList (PIM.CONTACT_LIST, PIM.READ_WRITE);} catch (PIMExceptione) {/ / ExitApplication} ContactsingleContact=addressBook.createContact (); String [] name= newString [addressBook.stringArraySize (Contact.NAME)]; if (addressBook.isSupportedField (Contact.NAME_FORMATTED) singleContact.addString (Contact.NAME_FORMATTED, PIMItem.ATTR_NONE, "Mrs.JaneDoe"); ThecreateContact () methodcreatesatemporaryemptyContact.Acommit () callmakes theContactdatapersistent.Itisadvisabletoclosethelistsbyinvokingtheclose () methodafternecessaryoperationshavebeenperformed. Try {singleContact.commit ();} catch (PIMExceptione) {/ / Exceptionoccured} try {/ / Othercleanuptasks addressBook.close ();} catch (PIMExceptione) {}
Event and EventList
An Event represents a single entry in an Event database, such as a calendar on a mobile device. The key fields in Event are Location, Summary, Startdate, EndDate, and Alarmnotification. Listing 2 shows how to add an Event to the Event database.
Listing 2. Add an Event
EventListeventList=null; try {eventList= (EventList) PIM.getInstance (). OpenPIMList (PIM.EVENT_LIST, PIM.READ_WRITE);} catch (PIMExceptione) {return;} EventsingleEvent=eventList.createEvent (); if (eventList.isSupportedField (Event.SUMMARY)) singleEvent.addString (Event.SUMMARY,PIMItem.ATTR_NONE, "JavaTraining"); if (eventList.isSupportedField (Event.START)) singleEvent.addDate (Event.START,PIMItem.ATTR_NONE,aDate.getTime ()) If (eventList.isSupportedField (Event.END)) singleEvent.addDate (Event.END,PIMItem.ATTR_NONE,aDate.getTime ()); try {singleEvent.commit ();} catch (PIMExceptione) {/ / Anerroroccured} try {eventList.close ();} catch (PIMExceptione) {}
ToDo and ToDoList
The ToDo interface represents a single task in the Task database on the mobile device, and the important fields are NoteorSummary, Priority, CompletionDate, DueDate, and whethercompleted. Listing 3 shows how to add a ToDo to database persistence.
Listing 3. Add a Task
ToDoListtasks=null; try {tasks= (ToDoList) PIM.getInstance (). OpenPIMList (PIM.TODO_LIST, PIM.READ_WRITE);} catch (PIMExceptione) {/ / Anerroroccurred return;} ToDosingleTask=tasks.createToDo (); if (tasks.isSupportedField (Event.SUMMARY)) singleTask.addString (ToDo.SUMMARY,PIMItem.ATTR_NONE, "ShoppingforHalloween"); if (tasks.isSupportedField (Event.DUE)) singleTask.addDate (ToDo.DUE,PIMItem.ATTR_NONE,newDate (). GetTime ()); try {singleTask.commit () } catch (PIMExceptione) {/ / Anerroroccured} try {tasks.close ();} catch (PIMExceptione) {}
The difference between PIM and RMS
Before continuing, let's review another key feature provided by J2ME, the RecordManagementStore (RMS) concept. RMS allows J2ME applications to store data locally permanently. RMS consists of the following components:
Unlike a database system in which each record has one or more fields, a Record in RMS is a separate data field. It does not have a predefined data type or size and can contain any data.
RecordStore--RecordStore is a collection of Records that can be accessed by name through a J2ME application.
The following is the difference between PIM and RMS, although both are responsible for storing persistent data on the device.
PIM stores (and retrieves) data from defined entities such as AddressBook, Calendar, and TaskList. RMS, on the other hand, stores (and retrieves) data from a regular database. A single entity in PIM is a Contact, Calendar entry, or a Task, while in RMS, a single entity is a byte array.
PIM is not limited to local devices, it can access data from an additional SIM or another remote device. RMS can only access data from the local device.
PIM can be imported or exported from external sources such as vCalendar or vContact, while RMS does not have any Export or Import functionality.
Compared with RMS, data interpretation in PIM is more flexible. For example, a Contact (defined in a standard format) can always be easily interpreted by another J2ME application. Records in RMS are byte arrays, and other J2ME applications need to have information about how to interpret it.
An example-add a contact
In this section, we will discuss the previously mentioned method addContact (), which shows how to add a contact to AddressBook. When a user command is submitted in the form, this method (see listing 4) is called in a separate thread. This method accesses the data entered through the UITextfields field.
Listing 4.addContact () method
/ / Import importjavax.microedition.lcdui.*; importjavax.microedition.midlet.*; importjavax.microedition.pim.*; / / Textinput TextFieldnameField; TextFieldphoneField;... PublicvoidaddContact () {ContactListcontacts=null; try {contacts= (ContactList) PIM.getInstance (). OpenPIMList (PIM.CONTACT_LIST, PIM.READ_WRITE);} catch (PIMExceptione) {/ / Anerroroccurred e.printStackTrace ();} Contactcontact=contacts.createContact (); String [] name= newstructure [contacts.stringArraySize (Contact.NAME)]; if (contacts.isSupportedArrayElement (Contact.NAME,Contact.NAME_GIVEN)) name [Contact.name _ GIVEN] = nameField.getString () If (contacts.isSupportedField (Contact.TEL)) contact.addString (Contact.TEL,Contact.ATTR_HOME,phoneField.toString ()); try {contact.commit ();} catch (Exceptione) {}}
Runtime and security issues
PIM MIDlet should run in a configuration that supports PIM (that is, JSR75). We select the following settings by clicking Settings and then APISelection on the WirelessToolkit2.5 of Sun. Use the same method when selecting the mobile device on which PIM MIDlet will run.
Figure 1.PIM MIDlet Runtime API Selection
MIDlet requires additional permissions to read and write Contacts, Calendar, or TaskLists, which can be set by clicking Settings in WirelessToolkit and selecting Permissions. All Read and Write permissions for ContactList, EventList, and TodoList are provided here.
Figure 2.PIM MIDlet security issues
We discussed another important feature in J2ME, Personal Information Management (PIM), which allows access to local data in the form of Contact, Task, and Event on mobile devices. This article also compares PIM with RMS, which is another function of processing device data. You can now synchronize J2ME applications with vCard and vCalendar through PIM's native import and export capabilities, which are the Internet standard formats for Contact and Calendar, respectively.
On how to understand the concept of J2ME PIM to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.