如何从SQLite android中的表中删除一行? [英] How to delete a row from a table in SQLite android?

查看:90
本文介绍了如何从SQLite android中的表中删除一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经这样做了,但它不起作用.我正在强制关闭.

I have done this and it is not working. I am getting force close.

public boolean favoriteDelete(int id) {
    return database.delete("FavoriteData", "Google" + "=" + id, null) > 0;
}

推荐答案

可以简单的使用sql查询删除.

You can simply use sql query to delete.

public void delete(String id) {
        db.execSQL("delete from "+TBL_NAME+" where Google='"+id+"'");
    }

在您的查询中,您使用 null 代替 whereArgs

In your query you are passing null in place of whereArgs

db.delete(table, whereClause, whereArgs)

应该是这样的

db.delete(TBL_NAME, "Google=?", new String[]{Integer.toString(id)});

这篇关于如何从SQLite android中的表中删除一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆