Android日历

TRI*_*ROR 6 android calendar insert exists

我正在尝试将项目放入日历中,并且无法真正找到如何对其进行编码.这是我到目前为止,但它将其插入主日历.

    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);
Run Code Online (Sandbox Code Playgroud)

所以我的问题是:

  1. 如何创建自己的日历以将事件放入

  2. 如何将我的事件插入该日历(使用上面的代码或新代码)

  3. 如何检查事件是否已存在

~~~更新:~~~

我要做的是我的用户将输入标题和日期,我的应用程序将采用该标题和日期,将它们放入数据库(到目前为止我所做的一切),现在我想拿标题和日期,并将它们放入专门用于我的应用程序事件的特殊日历中.我需要做的第一件事是让应用程序创建一个新的日历.比将事件插入到该日历中,下面的代码可以帮助我做些什么.还在玩它.比我想重新运行我的应用程序并检查事件是否存在.就这样.

nic*_*ild 0

  1. 您可以通过几种不同的方式来完成此操作,但我建议的最佳方式是使用SQLite 数据库来存储日历事件。
  2. 您将使用标准 SQL插入语句将事件添加到日历数据库中。
  3. 您将使用标准选择(查询)语句来检索事件。