日历查询
我正在尝试构建一个查询以从本机日历中获取事件,我已存储了以下 3 个单词中的 1 个单词的描述:“google”、“yahoo”、“stackoverflow”
例如:description="google",
As现在,我已经做了如下查询:
Cursor eventCursor = getContentResolver().query(builder.build(),
new String[] {"event_id", "title", "begin", "end", "allDay","description" }, "Calendars._id=" + calId,
null, "startDay ASC, startMinute ASC");
现在,我想用描述部分进行查询,我该怎么办?我当前的实现是错误的,请告诉我正确的方法,就好像你知道一样!
更新:
到目前为止我已经完成了:
public String Fetch_Events_Detail(long From_milliseconds, String kind_website)
{
String event_detail = null;
Uri.Builder builder = calendar_events_URI.buildUpon();
//long now1 = new Date().getTime();
ContentUris.appendId(builder, From_milliseconds);
ContentUris.appendId(builder, From_milliseconds + DateUtils.DAY_IN_MILLIS);
/* Cursor eventCursor = getContentResolver().query(builder.build(),
new String[] {"event_id", "title", "begin", "end", "allDay","description" }, "Calendars._id=? and description = ?",
new String[] { DatabaseUtils.sqlEscapeString(calId), DatabaseUtils.sqlEscapeString(kind_website)}, "startDay ASC, startMinute ASC");
*/
Cursor eventCursor = getContentResolver().query(builder.build(),
new String[] {"event_id", "title", "begin", "end", "allDay","description" },"Calendars._id=" + calId,
null, "startDay ASC, startMinute ASC");
if(eventCursor != null)
{
while (eventCursor.moveToNext())
{
String uid2 = eventCursor.getString(0);
String event_title = eventCursor.getString(1);
String event_start = eventCursor.getString(2);
String event_description = eventCursor.getString(5);
try
{
// SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
Date resultdate = new Date(Long.parseLong(event_start));
event_detail=sdf.format(resultdate)+" "+event_title;
event_detail.trim();
if(event_description.trim().equalsIgnoreCase(kind_website))
{
return event_detail;
}
}
catch(NumberFormatException e)
{
Log.i("Exception raised", "");
}
}
}
return null;
}
Thanx
I am trying to build a query for fetching the events from the native calendar, i have stored description with 1 word from the these 3 words: "google", "yahoo", "stackoverflow"
For example: description="google",
As of now, i have made query as below:
Cursor eventCursor = getContentResolver().query(builder.build(),
new String[] {"event_id", "title", "begin", "end", "allDay","description" }, "Calendars._id=" + calId,
null, "startDay ASC, startMinute ASC");
now, i would like to make query with Description part, how do i?? of my current implementation is wrong, please show me a correct way as if you know !!!
Update:
I have done so far:
public String Fetch_Events_Detail(long From_milliseconds, String kind_website)
{
String event_detail = null;
Uri.Builder builder = calendar_events_URI.buildUpon();
//long now1 = new Date().getTime();
ContentUris.appendId(builder, From_milliseconds);
ContentUris.appendId(builder, From_milliseconds + DateUtils.DAY_IN_MILLIS);
/* Cursor eventCursor = getContentResolver().query(builder.build(),
new String[] {"event_id", "title", "begin", "end", "allDay","description" }, "Calendars._id=? and description = ?",
new String[] { DatabaseUtils.sqlEscapeString(calId), DatabaseUtils.sqlEscapeString(kind_website)}, "startDay ASC, startMinute ASC");
*/
Cursor eventCursor = getContentResolver().query(builder.build(),
new String[] {"event_id", "title", "begin", "end", "allDay","description" },"Calendars._id=" + calId,
null, "startDay ASC, startMinute ASC");
if(eventCursor != null)
{
while (eventCursor.moveToNext())
{
String uid2 = eventCursor.getString(0);
String event_title = eventCursor.getString(1);
String event_start = eventCursor.getString(2);
String event_description = eventCursor.getString(5);
try
{
// SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
Date resultdate = new Date(Long.parseLong(event_start));
event_detail=sdf.format(resultdate)+" "+event_title;
event_detail.trim();
if(event_description.trim().equalsIgnoreCase(kind_website))
{
return event_detail;
}
}
catch(NumberFormatException e)
{
Log.i("Exception raised", "");
}
}
}
return null;
}
Thanx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不用 calId 试试这个
Try this without calId