?? recordmonitormidlet.java
字號:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
public class RecordMonitorMIDlet extends MIDlet
implements CommandListener,RecordListener {
private Command exitCommand;
private Command deleteCommand;
private Command changeCommand;
//The display for this MIDlet
private Display display;
RecordStore mainRS = null;
RecordStore backupRS = null;
public RecordMonitorMIDlet() {
display = Display.getDisplay(this);
exitCommand = new Command("離開", Command.EXIT, 1);
deleteCommand = new Command("刪除",Command.SCREEN,1);
changeCommand = new Command("修改",Command.SCREEN,1);
}
// Start the MIDlet by creating the TextBox and
// associating the exit command and listener.
public void startApp() {
TextBox aTextBox = new TextBox("主畫面",null,256,TextField.ANY);
byte[] nameEmail=null;
boolean existingOrNot = false;
boolean OK = true;
existingOrNot = existing("aRS1");
if(existingOrNot){
try{
mainRS = RecordStore.openRecordStore("aRS1",false);
mainRS.addRecordListener(this);
}
catch(Exception e){
OK = false;
}
finally{
if(OK){
aTextBox.setString("aRS已存在并且已打開");
}
else{
aTextBox.setString("aRS已存在但無法打開");
}
}
}
else{
try{
mainRS = RecordStore.openRecordStore("aRS1",true);
mainRS.addRecordListener(this);
}
catch(Exception e){
OK = false;
}
finally{
if(OK){
aTextBox.setString("aRS雖未存在,但已創建并完成打開的操作!");
}
else{
aTextBox.setString("aRS雖未存在,但無法創建,打開文件失敗!");
}
}
}
if(OK)
try{
backupRS = RecordStore.openRecordStore("aRS2",true);
}
catch(Exception e){
}
///*
if(OK)
try{
nameEmail = "JIDCA=login@ms16.hinet.net".getBytes();
mainRS.addRecord(nameEmail,0,nameEmail.length);
aTextBox.setString("已完成新增記錄的操作!");
}
catch(Exception e){
aTextBox.setString("新增記錄的操作失敗!");
}
String result = new String(nameEmail);
int position = result.indexOf('=');
result = "姓名:" + result.substring(0,position) + "\n" +
"E-mail
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -