我正在尝试将项目放入日历中,但不知道如何编写代码。到目前为止,这是我所拥有的,但它会将其插入到主日历中。
String calName;
String calId = null;
String[] projection = new String[] { "_id", "name" };
Uri calendars = Uri.parse("content://calendar/calendars");
Cursor managedCursor = managedQuery(calendars, projection, null, null, null);
ContentValues event = new ContentValues();
event.put("calendar_id", calId);
event.put("title", strTitle);
event.put("description", strDescription);
event.put("eventLocation", strLocation);
event.put("dtstart", StartTime);
event.put("dtend", EndTime);
Uri eventsUri = Uri.parse("content://calendar/events");
Uri calUri = getContentResolver().insert(eventsUri, event);
所以我的问题是:
如何创建自己的日历并添加事件
如何将我的事件插入到该日历中(使用上面的代码或新代码)
如何检查事件是否已经存在
~~~更新:~~~
我想做的是,我的用户将输入一个标题和日期,我的应用程序将获取该标题和日期,将它们放入数据库中(目前只完成了这一步),现在我想将标题和日期放入专门为我的应用程序事件而设的特殊日历中。首先,我需要让应用程序创建一个新的日历。然后将事件插入到该日历中,下面的代码有所帮助。还在尝试中。然后我想重新运行我的应用程序并检查事件是否存在。就这些。