跪求RMS 添加删除简单例子

来源:百度知道 编辑:UC知道 时间:2024/06/08 21:58:43
跪求!! 哪位大哥给写一个哈。。

保存一个游戏玩家的资料到RMS数据库
public static boolean saveRecord( UserInfo iUser ){
boolean ret = false ;
if( null != iUser && null != iUser.uid ){
try{
byte[] tem = iUser.outStream() ;//把iUser的个人信息编码成字节数组,具体怎么弄自己写吧,不懂再发贴问,篇幅有限我不写了
RecordStore iRecord = RecordStore.openRecordStore(iUserRecordName, true) ;//iUserRecordName是数据库的名字,自己可以定
int size = iRecord.getNumRecords() ;
if( 0 < size ){
iRecord.setRecord(1,tem, 0, tem.length);
}else{
iRecord.addRecord(tem, 0, tem.length);
}

tem = null ;
iRecord.closeRecordStore();
ret = true ;
}
catch(javax.microedition.rms.InvalidRecordIDException eo){
eo.printStackTrace();