簡體   English   中英

Android日歷

[英]Android Calendar

我正在嘗試將項目放入日歷中,但不知道如何對其進行編碼。 這是我到目前為止所擁有的,但它將它插入到主日歷中。

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

所以我的問題是:

  1. 如何創建自己的日歷以將事件放入

  2. 如何將我的事件插入該日歷(使用上面的代碼或新代碼)

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

~~~更新:~~~

我要做的是我的用戶將輸入標題和日期,我的應用程序將采用該標題和日期,將它們放入數據庫(到目前為止我所做的一切),現在我想采用標題和日期並將它們放入專門用於我的應用程序事件的特殊日歷中。 我需要做的第一件事是讓應用程序創建一個新日歷。 比將事件插入到下面的代碼幫助我做的那個日歷中。 還在玩它。 比我想重新運行我的應用程序並檢查事件是否存在。 就這樣。

首先,自 2.2 以來內容解析器發生了變化,我認為從content://calendar/calendarscontent://com.android.calendar/calendars

要插入事件,檢索事件檢查此代碼

https://github.com/Rabgs/AndroidLib_Google-Calendar/blob/master/src/net/mobiwide/agenda/google/GoogleAgenda.java

您將找到所需的一切以及如何處理跨平台的內容解析器更改。

  1. 您可以通過幾種不同的方式執行此操作,但我推薦的最佳方式是使用SQLite 數據庫來存儲您的日歷事件。
  2. 您將使用標准 SQL 插入語句將您的事件添加到您的日歷數據庫。
  3. 您將使用標准select(查詢)語句來檢索您的事件。

要更新 Google 日歷,請使用Google 日歷 GData API

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM