更新SQLite数据库时出错

时间:2017-04-23 09:11:09

标签: java

我想要更新hotelname =“”(EditText中的文字)的数据库。但我在我的类文件和同一方法{sqlitehelper)的updatedetails()文件中收到错误 我在哪里错了?

这是我的代码:SQliteHelper类

   public int updatedetails(String hotelname, String city, String desc, 
   String rooms, String price, byte[] image) {

    ContentValues updateValues=new ContentValues();
    updateValues.put("hotelname", hotelname);
    updateValues.put("city", city);
    updateValues.put("desc", desc);
    updateValues.put("rooms", rooms);
    updateValues.put("price", price);
    updateValues.put("image", image);
    return db.update("Hotel_info", updateValues, "hotelname" + "=" 
    +hotelname, null);
}

和AdminActivity类:

   sqLiteHelper.updatedetails( edtName.getText().toString().trim(),
    edtcity.getText().toString().trim(),
    edtdesc.getText().toString().trim(),
    edtrooms.getText().toString().trim(),
    edtPrice.getText().toString().trim(),
    imageViewToByte(imageView));
        }
    });

1 个答案:

答案 0 :(得分:0)

试试这段代码:

String[] hotelname= new String[]{hotelname};

db.update("Hotel_info", updateValues, "hotelname=?" , hotelname,null);