【问题标题】:How to delete/update data from my device calender如何从我的设备日历中删除/更新数据
【发布时间】:2011-07-14 20:53:35
【问题描述】:

实际上我已经创建了一个应用程序,我可以从中将笔记存储到我的设备日历中..现在可能存在我想要更改我的笔记并再次想要保存在设备日历中的情况..所以一切正常..但我想要的是当我将新数据从我的应用程序存储到设备日历时,以前存在的数据将从设备日历中删除,最重要的是,只有删除的数据是我的应用程序插入的那些数据,而不是已经存在的数据某人的设备日历..我的意思是说它删除了数据并插入了我的应用程序提供的新数据..我为在设备日历中存储数据而编写的代码如下所示..每当调用此函数时,我都想删除我以前从我的应用程序中保存的所有数据..

public void setAlertOnDevice()
    {   



            Date dtStartDate = CycleManager.getSingletonObject().getStartDate();

            boolean bDeleteAndReturn = false;

            Calendar cal = Calendar.getInstance();

            if (dtStartDate.getTime() ==  CycleManager.getSingletonObject().getDefaultDate().getTime())
            {
                    bDeleteAndReturn = true;
                    dtStartDate = cal.getTime();
            }  


            getOffsetsForCycleStages(CycleManager.getSingletonObject().iAvgCycleTime);
            if(bDeleteAndReturn==false)
            {
                if (CycleManager.getSingletonObject().bNextCycleAlert && iStart>0)
                {
                    cal.setTime(dtStartDate);
                    cal.add(Calendar.DATE, iStart);

                    Uri EVENTS_URI = Uri.parse(getCalendarUriBase(this) + "events");
                    ContentResolver cr = getContentResolver();
                    String str="SeeCycles: Start";
                    String strDescription="Cycle expected today. On start, enter the date into SeeCycles";
                    ContentValues values = new ContentValues();
                    values.put("calendar_id", 1);
                    values.put("title", str);
                    values.put("description", strDescription);
                    values.put("dtstart", cal.getTimeInMillis()); 
                    values.put("dtend", cal.getTimeInMillis()); 
                    cr.insert(EVENTS_URI, values);
                }
    }

【问题讨论】:

    标签: android


    【解决方案1】:

    如果您想修改用户的 Google 日历,请使用 Google 日历 GData API。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-04
      • 2022-01-25
      • 1970-01-01
      • 2018-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多