我得到了数据库条目并将它们显示在编辑文本中。我想改变它并更新它。但即使我能够更改,当我尝试从 EditText 获取文本时,它也会返回其旧值而不是更新值。
private void getServicesFromLayout(View view){
...........
if(checkDatabase() == null){
try{
companyNo = Integer.parseInt(mCompanyNumber.getText().toString());
seasonNo = Integer.parseInt(mPeriodNumber.getText().toString());
servicePath = mServicePath.getText().toString();
}catch (Exception e){
e.printStackTrace();
}
addNewService(servicePath,companyNo,seasonNo);
}else{
try{
**companyNo = Integer.parseInt(mCompanyNumber.getEditableText().toString());
seasonNo = Integer.parseInt(mPeriodNumber.getText().toString());
servicePath = mServicePath.getText().toString();**
}catch (Exception e){
e.printStackTrace();
}
int result = updateDatabase(servicePath ,companyNo ,seasonNo ,getEntryID());
Toast toast = Toast.makeText(globalContext,String.valueOf(result),Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
}
}
}
在这里,我正在检查数据库是否为空,如果它不为空,我将添加新服务,我正在尝试更新现有服务。但我无法从edittext 获得新价值。它返回旧值
mSaveConnectionInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try{
displayLatestEntry(getLatestServiceToDisplay());
if(isTestOk){
**getServicesFromLayout(v);**
isTestButtonClicked = 0;
这里叫...