当我点击自动完成列表视图时,我想更新Sq-lite db表中的特定行值。这是我的db帮助程序代码。
public boolean updateFilterUser(String strUserName)
{
SQLiteDatabase db = getWritableDatabase();
ContentValues values = new ContentValues();
values.put(COL_AllPost_ActivityStatus, "1");
values.put(COL_AllPost_inspectorname, strUserName);
int i = db.update(Table_AllPost_Table, values, COL_AllPost_inspectorname + "= ? ", new String[]{strUserName});
return i > 0;
}
这是活动代码
userAutoComplete_TextView = (AutoCompleteTextView) findViewById(R.id.autoComplete_UserList);
userAutoComplete_TextView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, userlist));
userAutoComplete_TextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
String foundItem = arg0.getItemAtPosition(arg2).toString();
boolean inputQuery = dbhelper.updateFilterUser(foundItem);
Log.e("Post ", " Edited Succesfully !!!" + inputQuery);
Filter filter = new Filter();
filter.setName(foundItem);
filter_ArrayList.add(filter);
filterAdapter = new FilterAdapter(Filter_Screen.this, R.layout.filter_list_item, filter_ArrayList);
listView_Filter.setAdapter(filterAdapter);
Log.e("Updated ListView --->", "" + foundItem);
}
});
我的行没有更新。
答案 0 :(得分:2)
请使用谎言,希望这对您有所帮助。
public boolean updateFilterUser(String strUserName){
SQLiteDatabase db = getWritableDatabase();
ContentValues values = new ContentValues();
values.put(COL_AllPost_ActivityStatus, "1");
String selection = COL_AllPost_inspectorname + " LIKE ?";
String[] selectionArgs = {strUserName};
int i = db.update(Table_AllPost_Table, values, selection, selectionArgs);
return true;
}