Android SQLite delete() 全部并返回值

编程入门 行业动态 更新时间:2024-10-21 16:20:22
本文介绍了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:

  • 如何通过 .delete() 方法删除给定表中的所有内容(我不想使用 .execSQL)
  • 它返回什么?游标还是整数?布尔值?
  • How do I delete everything in the given table (I do not want to use .execSQL) via the .delete() method
  • 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() 全部并返回值

    本文发布于:2023-06-04 19:11:19,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/503374.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:返回值   Android   SQLite   delete

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!