Java Reference
In-Depth Information
L ISTING 5.4 Continued
gau.setValue(4);
String msg = connect();
gau.setValue(6);
if (msg==null) {
s = “Connection Unavailable” ;
msg = “Please try again later.”;
licenseId = “”;
passwd = “”;
} else {
gau.setValue(8);
if(successfullyRegistered) {
save(licenseId, passwd);
s = “Registration Successful”;
} else {
licenseId = “”;
passwd = “”;
s = “Invalid License”;
}
}
Form f = new Form(s);
f.append(msg);
Display.getDisplay(midlet).setCurrent(f);
f.setCommandListener(this);
f.addCommand(new Command(“back”,Command.BACK,1));
}
if (c.getCommandType()==Command.BACK) {
Display.getDisplay(midlet).setCurrent(returnDisplayable);
}
}
/**
* save data persistently
*/
private void save(String id, String pwd) {
try {
String scrambled = scramble(licenseId);
keyStore.setRecord(1, scrambled.getBytes(), 0, scrambled.getBytes()
.length);
scrambled = scramble(passwd);
keyStore.setRecord(2, scrambled.getBytes(), 0,
scrambled.getBytes().length);
//close the recordStore
Search WWH ::




Custom Search