2013-07-12 59 views
0

我知道我錯過了一些簡單的東西。我做了一個網站管理員,使用SQLite來跟蹤ftp地址,登錄詳細信息,主目錄,url等。我有一個Activity,它允許用戶選擇和編輯網站的詳細信息當單擊Update按鈕時,它更新網站的行在數據庫中,但我無法保存的唯一數據庫值是網站遠程目錄的變量_remoteHomeDir。爲什麼不更新這個值?爲什麼這個字段沒有在SQLLite數據庫中更新?

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; 
} 
+0

檢查你的行ID值,是否有效 –

+0

它必須是如果它適用於每個領域,但一個不是嗎? – RapsFan1981

回答

1

看起來你正在閱讀的兩個_url和_remoteHomeDir從EditText上siteManHome相同的值。這可能是一個錯誤,可能是你在GUI

即有單獨的編輯文本:

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

也許你的意思是讓來自不同領域的_remoteHomeDir

+0

啊,謝謝。愚蠢的深夜編碼錯誤。 – RapsFan1981

+0

感謝@janos編輯我的答案。我從手機回答,所以沒有選擇格式化(更不用說如果有選擇會有多難)。 –

+0

@ RapsFan1981很高興它幫助。 –

相關問題