[英]Sqlite :Update query is not updating value to database
I try to update local database using update query while clicking in this increment button.this function is in baseadapter.我尝试在单击此增量按钮时使用更新查询来更新本地数据库。这个 function 在 baseadapter 中。 during a long press in the listview a listview popup will occur there iam need trying to call this function to update Qty in database.在列表视图中长按期间,将出现一个列表视图弹出窗口,我需要尝试调用此 function 来更新数据库中的数量。 sqlite database is used.使用 sqlite 数据库。
holder.mPlusitem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
count[0]++;
holder.sSelectQty.setText(String.valueOf(count[0]));
descriptionDb.UpdateDescQty(mData[position][0],String.valueOf(count[0])); // to update incremented value to the datdabase
}
});
In updatequery used to update在updatequery中用于更新
public void UpdateDescQty(String ItemID, String Qty) {
ContentValues values = new ContentValues();
values.put(Qty(), Qty)
String[] args = new String[]{ItemID};
database.update(TableName, values,Id() + "=?", args);
}
I tried this method also to updated我也试过这种方法来更新
database.update(TableName(),values, " "+cId()+"="+ ItemID, null);
There is no any error but it is not entry value in to the database,没有任何错误,但它不是数据库中的条目值,
Try with试试
public void UpdateDescQty(String item_id, String qty) {
ContentValues values = new ContentValues();
values.put(QsDatabaseHelper.getDescDescQty(), qty);
database.update(QsDatabaseHelper.getDescTableName(),
values,sDatabaseHelper.getDescDescId() + " = "+item_id, null);
}
SYNTAX句法
update(Tablename, ContentValues Object, "Primary_Key=" + Prinary_key_value, null);
I find the mistake.我发现了错误。
Code working perfectly but i didnt settext where qty is displaying.代码运行完美,但我没有在显示数量的地方设置文本。
holder.sSelectQty.setText(VALUE FROM DATABASE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.