android - Android Sqlite 通过“selection”和“selectionArgs”搜索日期
问题描述
我使用类似于以下代码的代码在两个日期之间搜索数据库:
cursor.query(select column from Table where columnDate between '2018-09-20' and '2018-09-23');
但现在我想使用 queryprojection
和.selection
selcetionArgs
如何更新我的代码?
解决方案
你可以使用这个:
cursor.query("Table" ,
new String[]{"column"},
"columnDate BETWEEN ? AND ?",
new String[]{"2018-09-20","2018-09-23"},
null/*Group by if you need*/,
null/*having if you need*/,
null/*order by if you need*/);
推荐阅读
- git - 在这种情况下,repo 中可能不存在合并 PR 的提交?
- java - Android Java 从 Fragment 内部更改 Fragment 而不是 Fragment Activity
- java - Spring数据jpa集合不更新
- python - django 使用了错误的 django 版本,尽管我使用 pipenv 安装了特定版本
- php - 使用带有 try and catch 的 Symfony HTTP 客户端
- laravel - 登录 Lumen 7.0 和 JWT 时如何检查用户状态
- arrays - Google 表格中的外部联接
- nginx - 区分大小写/不区分大小写的匹配在 nginx 中不起作用
- javascript - Vuex:如何从服务脚本文件状态更改存储状态未定义
- download - setText() 仅在命令之后而不是之前有效