15
Phonebook Access API
In the Motorola E680, Phonebook API permissions have been added to the MIDP 2.0
security framework "com.motorola.phonebook." The behavior is up to the domain setting
where the MIDlet falls in. For an untrusted MIDlet, the permission for the API is "Oneshot".
The following are code samples to show implementation of the Phonebook API:
Sample of code to create object of PhoneBookRecord class:
PhoneBookRecord phbkRecEmpty = new PhoneBookRecord();
String name = "Name";
String telNo = "9999999";
int type = PhoneBookRecord.MAIN;
PhoneBookRecord phbkRec = new PhoneBookRecord(name, telNo,
type);
Sample of code for calling of 'add()' method:
int index = phbkRec.add();
Sample of code for calling of 'update(int index)' method:
phbkRec.type = PhoneBookRecord.HOME;
int newIndex = phbkRec.update(index);
Sample of code for calling of 'delete(int index)' method:
PhoneBookRecord.delete(index);
Sample of code for calling of 'deleteAll()' method:
PhoneBookRecord.deleteAll();
Sample of code for calling of 'getRecord(int index)' method:
phbkRec.getRecord(index);
Sample of code for calling of 'findRecordByTelNo(String tel)' method:
index = phbkRec.findRecordByTelNo(telNo);
Sample of code for calling of 'findRecordByName(char firstChar)' method:
index = PhoneBookRecord.findRecordByName('N');
Sample of code for calling of 'findRecordByEmail(String email)' method:
String email = "email@mail.com";
index = phbkRec.findRecordByEmail(email);
Sample of code for calling of 'getNumberRecords(int device)' method:
61