我有我的数据库,我查询它的所有项目。
物品清单如下:
Type- Coffee: Name- Cafe Latte
Type- Coffee: Name- Flavoured Latte
Type- Coffee: Name- Mocha
Type- Coffee: Name- Americano
Type- Coffee: Name- Short Black
Type- Coffee: Name- Flat White
Type- Coffee: Name- Espresso
Type- Coffee: Name- Espresso Con Panna
Type- Coffee: Name- Espresso Machiato
Type- Coffee: Name- Espresso Affogato
Type- Coffee: Name- Pot Of Coffee
当我调用这个函数时:
public int EditItem(MenuItem menuItem){
ContentValues itemNewValues = new ContentValues();
//itemNewValues.put(ITEM_TYPE,menuItem.getType());
itemNewValues.put(ITEM_NAME,menuItem.getName());
itemNewValues.put(ITEM_REGPRICE,menuItem.getRegPrice());
itemNewValues.put(ITEM_LARGEPRICE,menuItem.getLargePrice());
String[] args = new String[1];
args[0]= menuItem.getName();
return db.update(DATABASE_TABLE, itemNewValues,ITEM_NAME+"=?", args);
}
Log.i("TAG","updating (no of entries edited: " +localDBHandler.EditItem(new MenuItem("Coffee", "Flavoured Latte", "9.90","2.45")));
它返回“已编辑的条目数:2”
但是当我再次打印出表格时,它完全一样。
哦,这是我的创建表语句:
// SQL Statement to create a new database.
private static final String DATABASE_CREATE = "create table " +
DATABASE_TABLE + " (" +
ITEM_TYPE + " text not null, " +
ITEM_NAME + " text not null, " +
ITEM_REGPRICE + " text not null, " +
ITEM_LARGEPRICE + " text not null);";
它困扰着我,因为我不希望不想要的变化出现在我刚刚没有看到的更远的地方。