Android SQLite delete() 全部并返回值 [英] Android SQLite delete() all and return value

查看:57
本文介绍了Android SQLite delete() 全部并返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我发现的一个简短片段:

This is a short snippet I found:

"删除数据

一旦不再需要数据,可以使用以下命令将其从数据库中删除删除()方法.delete() 方法需要 3 个参数,数据库名称、WHERE 子句和 WHERE 的参数数组条款.要从表中删除所有记录,请为 WHERE 传递 null子句和 WHERE 子句参数数组.

Once data is no longer needed it can be removed from the database with the delete() method. The delete() method expects 3 parameters, the database name, a WHERE clause, and an argument array for the WHERE clause. To delete all records from a table pass null for the WHERE clause and WHERE clause argument array.

db.delete("tbl_states", "id=?", new String[] {Long.toString(countryId)});

db.delete("tbl_states", "id=?", new String[] {Long.toString(countryId)});

只需调用 delete() 方法即可从 SQLite 数据库中删除记录.delete 方法需要表名和可选的where 子句和 where 子句参数替换数组为参数.where 子句和参数替换数组只工作与更新在哪里?由数组中的值替换."

Simply call the delete() method to remove records from the SQLite database. The delete method expects, the table name, and optionally a where clause and where clause argument replacement arrays as parameters. The where clause and argument replacement array work just as with update where ? is replaced by the values in the array."

像往常一样,我找不到关于以下内容的简单文档:

As usual I cannot find simple documentation as to:

  1. 如何通过 .delete() 方法删除给定表中的所有内容(我不想使用 .execSQL)
  2. 它返回什么?游标还是整数?布尔值?
  1. How do I delete everything in the given table (I do not want to use .execSQL) via the .delete() method
  2. What does it return? A cursor or interger? boolean?

推荐答案

null 传递给 WHERE 子句和参数数组将删除所有内容(想想如果没有 WHERE 子句你所说的是从 tbl_states 中删除).

Passing in null to the WHERE clause and argument array will delete everything (think if there is no WHERE clause all you are saying is delete from tbl_states).

delete 以整数形式返回删除的行数.

delete returns the number of rows deleted as an integer.

这篇关于Android SQLite delete() 全部并返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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