簡體   English   中英

更新SQLite數據庫時出錯

[英]Error while updating SQLite Database

我要更新數據庫,其中hotelname =“”( EditText的文本)。 但是我在同一個方法的類文件和sqlitehelper文件中出現updatedetails() { 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));
        }
    });

試試這個代碼:

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM