我正在开发一个应用程序,它将用户名和密码存储在RMS中,该应用程序在诺基亚s60上运行良好,但在诺基亚s40手机中,应用程序给出非法参数异常,然后应用程序被关闭。如果它在 S60 手机上工作正常,我无法理解问题是什么。
public void getLogin() {
//System.out.println(getUsernameEdit().getString()+","+ getPasswordEdit().getString());
m=new Message();
reply=m.getLogin(getUsernameEdit().getString(), getPasswordEdit().getString());
if (reply) {
String response="";
try{
if(count==0){
rs = RecordStore.openRecordStore(db, true);
rs.addRecord("true".getBytes(), 0, "true".length());
rs.addRecord(getUsernameEdit().getString().getBytes(), 0, getUsernameEdit().getString().length());
rs.addRecord(getPasswordEdit().getString().getBytes(), 0, getPasswordEdit().getString().length());
rs.closeRecordStore();
}
else{
rs = RecordStore.openRecordStore(db, false);
byte b[]=rs.getRecord(1);
response=new String(b,0,b.length);
System.out.println(response);
if(response.equals("true")){
rs.setRecord(2, getUsernameEdit().getString().getBytes(), 0, getUsernameEdit().getString().length());
rs.setRecord(3, getPasswordEdit().getString().getBytes(), 0, getPasswordEdit().getString().length());
}
rs.closeRecordStore();
getSenderEdit().setString(getUsernameEdit().getString());
}
}catch(Exception e){
getErrorBox().setString(e.toString());
}
switchDisplayable(getSavingSuccess(), getMessageForm());
// write post-action user code here
} else {
// write pre-action user code here
switchDisplayable(getSavingError(), getSettings());
// write post-action user code here
}
// enter post-if user code here
}
为什么不尝试使用 Storage 类?RMS在lwuit中的演变