【发布时间】:2017-08-14 17:56:51
【问题描述】:
我正在使用此代码来更新值
此代码正常工作而没有错误查询中没有错误但是当我在更新它显示旧数据后显示数据时??
这是我用来更新 sqlite 中数据的代码。
@Override
public void onClick(View v) {
if (v == Update) {
try {
ContentValues CV = new ContentValues();
CV.put("cname", EditName.getText().toString());
CV.put("mobileno", EditMobile.getText().toString());
CV.put("phone", EditLandline.getText().toString());
CV.put("address", EditAddress.getText().toString());
CV.put("email", EditEmail.getText().toString());
CV.put("picture", Editbytes);
DB.update("contacts", CV, "cname=" + V,null);
Intent I = new Intent(ctx, ContactList.class);
ctx.startActivity(I);
// DB.execSQL("insert into contacts values('" + Name.getText() + "','" + Mobile.getText() + "','" + Phone.getText() + "','" + Add.getText() + "','" + Email.getText() + "')");
Toast.makeText(ctx, "Contact Updated...",Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(ctx, "Fail to Update Contact.." + e, Toast.LENGTH_LONG).show();
}
} else if (v == Delete) {
}
}
【问题讨论】:
-
更新你的数据库版本可能会解决问题
-
请添加更多信息,如 SQLite 版本、数据库配置等。
-
请添加完整的文件列表和 gradle 依赖项列表。如果
DB类也是你的,也添加它的列表。 -
我使用的是 1.12.0 sqlite 版本
-
DB 不是 SqliteDatabase 变量的类