Android Sqlite通过“选择”和“ selectionArgs”搜索日期

时间:2018-09-23 07:36:11

标签: android sqlite android-sqlite

我使用类似于以下代码的代码在两个日期之间搜索数据库:

cursor.query(select column from Table where columnDate between '2018-09-20' and '2018-09-23');

但是现在我想使用查询projectionselectionselcetionArgs

如何更新代码?

1 个答案:

答案 0 :(得分:1)

您可以使用此:

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*/);