Motorola C450 User Manual

Page of 86
 
Phonebook Access API Permissions 
Prior to a MIDlet accessing the Phonebook API for all Phonebook operations, the 
implementation will check the Phonebook permissions under the Java Settings Menu. The 
phonebook permissions menu gives the user the following options: 
• 
Always ask the user for authorization on all Phonebook access requests 
• 
Ask the user for authorization once per application (Default setting) 
• 
Never ask the user for authorization 
 
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; 
int categoryId = PhoneBookRecord.CATEGORY_GENERAL; 
 
PhoneBookRecord phbkRec = new PhoneBookRecord(name, telNo, type, 
categoryId); 
 
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);