Motorola HANDSET C381P User Manual
Page 50
11
Phonebook Access API
50
In the Motorola C381p, 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 Code Sample 6 shows the 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,
PhoneBookRecord.CATEGORY_GENERAL);
Sample of code for calling of ‘add(int sortOrder)’ method:
int index = phbkRec.add(PhoneBookRecord.SORT_BY_NAME);
Sample of code for calling of ‘update(int index, int sortOrder)’ method:
phbkRec.type = PhoneBookRecord.HOME;
int newIndex = phbkRec.update(index, PhoneBookRecord. SORT_BY_NAME);
Sample of code for calling of ‘delete(int index, int sortOrder)’ method:
PhoneBookRecord.delete(index, PhoneBookRecord. SORT_BY_NAME);
Sample of code for calling of ‘deleteAll()’ method:
PhoneBookRecord.deleteAll();
Sample of code for calling of ‘getRecord(int index, int sortOrder)’ method:
phbkRec.getRecord(index, PhoneBookRecord.SORT_BY_NAME);
Sample of code for calling of ‘findRecordByTelNo(String tel, int sortOrder)’ method:
index = phbkRec.findRecordByTelNo(telNo,
PhoneBookRecord.SORT_BY_NAME);
Sample of code for calling of ‘findRecordByName(char firstChar, int sortOrder)’ method:
index = PhoneBookRecord.findRecordByName('N',
PhoneBookRecord.SORT_BY_NAME);
Sample of code for calling of ‘findRecordByEmail(String email, int sortOrder)’ method:
String email = “[email protected]”;
index = phbkRec.findRecordByEmail(email,
PhoneBookRecord.SORT_BY_NAME);