SqLite delete不能删除数据记…

 

删除一般的格式是:DELETE FROM 表名称 WHERE 列名称 = 值

一直返回false;(删除失败)

在通常情况下,我一般会犯2个错误:

1.如果是属性的话应该是不能删除的,主键字段不能被修改,其他字段只能赋空值了。

  这个可以在创建表的时候修改,把条件字段不要设置成属性字段。

  CREATE_TABLE = "CREATE TABLE "
   + TABLE_NAME_FAVRORITE + " (" + KEY_ID + " INTEGER PRIMARY KEY,"
   + KEY_LATITUDE + "," + KEY_LONGITUDE + "," + KEY_TYPE + " ,"
   + KEY_NAME + "," + KEY_VIDEO_URL + " ," + KEY_DEPARTMENT + " ,"
   + KEY_XINGZHENGQU + " ," + KEY_MACHINE_TYPE + " ," + KEY_RESOLUTION
   + " ," + KEY_CODE + " TEXT)";

 

2.忘了加单引号.你的title是
NVARCHAR的吧,应该是
return db.delete(DATABASE_TABLE, KEY_TITLE +"=‘" + title+“’” , null)>0;
title要。。加单引号、

 

return mSQLiteDatabase.delete(TABLE_NAME_FAVRORITE, KEY_CODE + "='"
     + codeId + "'", null) > 0;

你可能感兴趣的:(android)