Motorola C381P technical manual Sample of code for calling of ‘addint sortOrder’ method

Models: C381P

1 130
Download 130 pages 15.6 Kb
Page 50
Image 50

11

Phonebook Access API

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@mail.com”;

index = phbkRec.findRecordByEmail(email, PhoneBookRecord.SORT_BY_NAME);

50

Page 50
Image 50
Motorola C381P technical manual Sample of code for calling of ‘addint sortOrder’ method