工作搞个J2ME程序,测试时候发现RMS数据只能在程序运行时保存,并没有真正生成.db文件。
解决方法,在开始菜单Sun JAVA Wireless Toolkit 2.5.1 for CLDC栏中运行Preferences,跳出偏好框,在里面的存储栏的存储根目录填写.\DefaultColorPhone (因为默认的相对路径是C:\WTK2.5.1\appdb)
问题解决了
另外,RMS中的RecordEnumeration是一个环形结构
//得到RMS中所有记录信息,返回vector public Vector getRecords(){ try{ //需要根据不同操作取得不同的排序 RecordEnumeration re = rs.enumerateRecords(null,null,false); int length = re.numRecords(); Vector records=new Vector(); if(length == 0){ return null; }else{ int i = 0; // while(re.hasNextElement()){ // re.nextRecord(); // // byte[] data = re.nextRecord(); // records.addElement(data); // // } re.reset(); while(re.hasPreviousElement()){ byte[] data = re.previousRecord(); records.addElement(data); } return records; } }catch(RecordStoreException ex){ ex.printStackTrace(); return null; } }
这段程序中如果是用的next的方法,则得到的Vector里面的对象是逆序的,比如我按顺序放1,2,3取出来的时候就成了3,2,1。所以我用的是previous的方法 |