« | August 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | | | | | |
|
统计 |
blog名称:小雨 日志总数:262 评论数量:1273 留言数量:15 访问次数:4665865 建立时间:2005年1月8日 |
| 
|
W3CHINA Blog首页 管理页面 写新日志 退出
[知识积累]j2me rms |
小雨 发表于 2007/3/31 16:57:09 | import javax.microedition.rms.*;import javax.microedition.lcdui.*;import javax.microedition.midlet.*;import javax.microedition.io.*;import java.util.Enumeration;import java.io.*;public class testRms extends MIDlet implements CommandListener{ List list,choose; Command back; Display display ; RecordStore rs=null; public void startApp() { display=Display.getDisplay(this); back=new Command("back",Command.BACK,1); choose=new List("show",List.IMPLICIT); list=new List("select list",List.IMPLICIT); list.append("add",null); list.append("view",null); list.append("delete",null); list.setCommandListener(this); choose.addCommand(back); choose.setCommandListener(this); display.setCurrent(list); } public void pauseApp() { } public void destroyApp(boolean uncondition){ } public void commandAction(Command c,Displayable d) { if(c.getCommandType()==Command.BACK) display.setCurrent(list); if(list.getSelectedIndex()==0) { try { rs=RecordStore.openRecordStore("sampledata",true); byte[] bytestr="hello,rms".getBytes(); int id=rs.addRecord(bytestr,0,bytestr.length); System.out.println(id); }catch(Exception ex){ } } if(list.getSelectedIndex()==1) { byte[] bytestr=null; try { if (rs==null) rs=RecordStore.openRecordStore("sampledata",false); RecordEnumeration re=rs.enumerateRecords(null,null,false); while(re.hasNextElement()) { String theList=new String(re.nextRecord()); choose.append(theList,null); } } catch(Exception e) {} display.setCurrent(choose); } if(list.getSelectedIndex()==2) { try { if (rs==null) rs=RecordStore.openRecordStore("sampledata",false); RecordEnumeration re=rs.enumerateRecords(null,null,true); while(re.hasNextElement()) { int id=re.nextRecordId(); rs.deleteRecord(id); System.out.println(id); } } catch(Exception e) { } } }}
|
阅读全文(2885) | 回复(0) | 编辑 | 精华 |
|