📄 midlet2.java
字号:
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.rms.*;
public class midlet2 extends MIDlet{
public midlet2() {
// TODO Auto-generated constructor stub
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
try{rs.closeRecordStore();}
catch(Exception e)
{e.printStackTrace();}
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
RecordStore rs=null;
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
try{
rs=RecordStore.openRecordStore("test1", true);
MyListener myListener=new MyListener();
rs.addRecordListener(myListener);
//rs.deleteRecordStore("test");
//String str="lkkkkk";
//byte[] data=str.getBytes();
//int id=rs.addRecord(data, 0, data.length);
//System.out.println(id);
//rs.deleteRecord(1);
//
//String a="xx";
//byte[] d=a.getBytes();
//rs.setRecord(6, d, 0, d.length);
////byte[] newdata=rs.getRecord(4);
////String str2=new String(newdata);
////System.out.println(str2);
//int n=rs.getNumRecords();
//System.out.println(n);
RecordEnumeration re=rs.enumerateRecords(null, null, true);
while(re.hasNextElement())
{
byte[] d3=re.nextRecord();
String str3=new String(d3);
System.out.println("str3"+str3);
}
}catch(Exception e)
{e.printStackTrace();}
}
}
class MyListener implements RecordListener
{
public void recordAdded(RecordStore arg0, int arg1) {
System.out.println("recordAdded");
}
public void recordChanged(RecordStore arg0, int arg1) {
System.out.println("recordChanged");
}
public void recordDeleted(RecordStore arg0, int arg1) {
System.out.println("recordDeleted");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -