0

我知道我错过了一些简单的东西。我制作了一个网站管理器,用于SQLite跟踪 ftp 地址、登录详细信息、主目录、url 等。我有一个Activity允许用户选择和编辑网站详细信息的网站管理器,当单击更新按钮时,它会更新网站中的行database 但是我无法保存的唯一数据库值是_remoteHomeDir网站远程目录的 var。为什么这个值不更新?

siteManUpdateBtn.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        _address = siteManFTPAddress.getText().toString();
        _username = siteManFTPUsername.getText().toString();
        _password = siteManFTPPassword.getText().toString();
        String port = siteManFTPPort.getText().toString();
        _port = Integer.parseInt(port);
        _url = siteManHome.getText().toString();
        _remoteHomeDir = siteManHome.getText().toString();
        Toast.makeText(SiteManager.this, "Update", Toast.LENGTH_LONG).show();

    myDb.updateRow(_rowId, _name,  _name, _isLive, _address, _username, _password, _port, _url,_remoteHomeDir);
    model.clear();
    adapter.notifyDataSetChanged();
    displayRecords();
    }
});

DBAdapter.java

public boolean updateRow(long rowId, String name, String homedir,
    int islive, String address, String username, String password,
    int port, String url, String rhome) {
String where = KEY_ROWID + "=" + rowId;

/*
 * CHANGE 4:
 */
// TODO: Update data in the row with new fields.
// TODO: Also change the function's arguments to be what you need!
// Create row's data:
ContentValues newValues = new ContentValues();
newValues.put(KEY_NAME, name);
Log.d("tag", "there is something happening here: " + name);
newValues.put(KEY_HOME, homedir);
Log.d("tag", "there is something happening here: " + homedir);
newValues.put(KEY_LIVE, islive);
Log.d("tag", "there is something happening here: " + islive);
newValues.put(KEY_ADDRESS, address);
Log.d("tag", "there is something happening here: " + address);
newValues.put(KEY_USERNAME, username);
Log.d("tag", "there is something happening here: " + username);
newValues.put(KEY_PASSWORD, password);
Log.d("tag", "there is something happening here: " + password);
newValues.put(KEY_PORT, port);
Log.d("tag", "there is something happening here: " + port);
newValues.put(KEY_URL, url);
Log.d("tag", "there is something happening here: " + url);
newValues.put(KEY_RHOME, rhome);
Log.d("tag", "there is something happening here: " + rhome);
// newValues.put(KEY_PASSIVE, passive);
// Insert it into the database.
Log.d("tag", "there is something happening here: " + db.toString());
return db.update(DATABASE_TABLE, newValues, where, null) != 0;
}
4

1 回答 1

1

看起来您正在从 edittext siteManHome 读取 _url 和 _remoteHomeDir 的相同值。这可能是一个错误,可能是您在 GUI 中有单独的编辑文本

那是:

_url = siteManHome.getText().toString();
_remoteHomeDir = siteManHome.getText().toString();

也许你打算_remoteHomeDir从不同的领域获得?

于 2013-07-13T04:16:40.093 回答