android - 在 SQLite Android 中使用多个 WHERE 删除行

标签 android sqlite where delete-row

这是删除具有多个 WHERE 参数的行的正确方法吗?我正在努力使其对数据库查询尽可能安全。

db.delete(TABLE, NAME + "=? and " + ID + "=? and " + ARG3 + "=?", new String[] { myName, x, argument3 });

还有,ID 是整数可以吗?为此,我还能在 String[] 中使用它吗?

最佳答案

你的方法看起来不错。


Also is it okay that ID is a integer? Can I still use it inside String[] for this?

您的编译器是回答这个问题的最佳方式。

但是,如果 x(例如)是一个整数,您可以使用以下任一方法:

new String[] { x + "" };
new String[] { String.valueOf(x) };

如果您担心 "=? 和 "+ ID + "=? 和 " 中的 ID 会给您带来错误,请不要担心它不会'

关于android - 在 SQLite Android 中使用多个 WHERE 删除行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13148436/

相关文章:

android - java.lang.NoClassDefFoundError : com. 谷歌.android.maps.GeoPoint

android - 实现能够接收推送通知并启动网络浏览器的应用程序

android - 可以检查哪些回调已添加到 Android 处理程序?

c# - 如何在 .net 中使用 sqlite 和 crystal report 创建报告

sql - Crystal Reports 中 WHERE 子句的等效项

sql - 为什么我不能在SQL Server的CASE语句列上使用filter我的WHERE子句?

sql - WHERE 子句谓词可以评估为 NULL 吗?

android - Android:出现错误:添加新依赖项后,任务 ':app:processDebugGoogleServices'的执行失败

python - 我应该为每个 Sqlite3 事务调用 connect() 和 close() 吗?

c# - 在使用 SQLite 之前有什么注意事项吗?