嗨:在插入方法中使用 UserDAO 类插入查询存在返回类型不匹配问题。我有很多字段,但我想向少数字段插入数据。请帮助我提前谢谢。
Veiwholder.btnSave.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String Firstname =Veiwholder.etFirstName.getText().toString();
String Lastname =Veiwholder.etLastName.getText().toString();
String Password =Veiwholder.etPassword.getText().toString();
UsersDAO userDAO = new UsersDAO(NewDataEnteryActivity .this);
Users userDO = userDAO.AddNewRecod(Firstname, Lastname, Password);
}
});
}
这是另一个 userDaO 类代码。这也是我的查询类。
public int AddNewRecod(String FirstName,String LastName,String Password ) {
int row_id = -1;
try {
OpenConnection(context);
ContentValues contentValue = new ContentValues();
contentValue.put(Users.FIELD_FIRST,userDO.getfirstName());
contentValue.put(Users.FIELD_LAST_NAME,userDO.getLastName());
//contentValue.put(Users.FIELD_EMAIL, userDO.GetEmail());
contentValue.put(Users.FIELD_PASSWORD,userDO.getpassword());
//contentValue.put(Users.FIELD_CREATION_DATE,userDO.GetCreationDate());
//contentValue.put(Users.FIELD_IS_ACTIVE, userDO.GetIsActive());
row_id = (int) dbSqlLiteDataObject.insert(Users.TABLE_USERS, null,
contentValue);
CloseConnection();
} catch (SQLiteException ex) {
CloseConnection();
Log.e("Insert " + Users.TABLE_USERS
+ "into database exception caught", ex.getMessage());
row_id = -999;
}
return row_id;
}