www.pudn.com > j2mewireless_examples.zip > PopulateAddressBook.java
/*
* Copyright (c) 2000-2001 Sun Microsystems, Inc. All Rights Reserved.
*/
package examples.addressbook;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;
/**
* Class to create an example address book and populate it
* with some records
*/
public class PopulateAddressBook extends MIDlet {
private final String personalNames[] = {
"John", "Zach", "2225556669",
"Mark", "Lynn", "5125551212",
"Joy", "Beth", "2705551234",
"Abby", "Lynn", "4085558566",
"Ted", "Alan", "4125552235",
"Sterling", "Wincle", "9995559111",
"Deborah", "Elaine", "4445552323",
"Suzanne", "Melissa","5125556064",
"Frank", "Kenneth", "7775551212",
"Dwight", "Poe", "1115557234",
"Laura", "Beth", "2055558888",
"Lisa", "Dawn", "2705551267",
"Betty", "June", "5555551556",
"Yvonne", "Poe", "6665558888",
"Lizzy", "Loo", "5025557971",
"John", "Gerald", "3335551256",
"Mark", "VandenBrink", "1115557878",
"Roger", "Riggs", "3335550000",
"Antero", "Taivalsaari", "9995552222"
};
public PopulateAddressBook() {
RecordStore rs;
RecordEnumeration re;
CreateAddressBook.createRecordStore("TheAddressBook",
personalNames);
try {
rs = RecordStore.openRecordStore("TheAddressBook", true);
re = rs.enumerateRecords(null, null, false);
while (re.hasNextElement()) {
byte[] b = re.nextRecord();
System.out.println("<" + SimpleRecord.getFirstName(b) + ">" +
"<" + SimpleRecord.getLastName(b) + ">" +
"<" + SimpleRecord.getPhoneNum(b) + ">");
}
} catch (Exception e) {
System.out.println("Houston, we have a problem: " + e);
}
}
/**
* Called by the system to start our MIDlet.
*/
protected void startApp() {
destroyApp(false);
notifyDestroyed();
}
/**
* Called by the system to pause our MIDlet.
* No actions required by our MIDLet.
*/
protected void pauseApp() {}
/**
* Called by the system to end our MIDlet.
* No actions required by our MIDLet.
*/
protected void destroyApp(boolean unconditional) {}
}