【发布时间】:2013-03-06 20:24:49
【问题描述】:
我正在查询 android 中的事件表以获取事件。
String[] projection = new String[] { "calendar_id", "title", "description",
"dtstart", "dtend", "eventLocation" };
Cursor cursor = cr.query(Uri.parse("content://com.android.calendar/events"),
projection,
null,
null,
null);
这将返回所有事件。但现在我只想要特定持续时间的事件,比如 2013 年 4 月 3 日到 2013 年 7 月 3 日。如何使用 selection 和 selectionArgs[] ?
我试过这个
String selection = "((dtstart <= ?) AND (dtend >= ?))";
String[] selectionArgs = new String[] {startString, endString};
但它没有返回任何东西。我的疑问是
1. where 子句会起作用吗?因为, startDate 和 endDate 先转换为 long(毫秒),然后转换为 String,然后存储在表中。那么如何比较字符串的长值。 sqlite 中没有toNumber() 函数。
2.如果我传递selectionArgs,那么startString和endString应该是哪种格式?
【问题讨论】:
标签: android events calendar selection