如何在我的应用程序中在android中保存提醒

时间:2011-08-09 10:40:03

标签: android android-calendar

我正在尝试为Android开发一个应用程序,其中我需要获取所有日历条目(提醒),保存在手机日历中,我该如何获取它们?我可以在android模拟器上做到吗?

2 个答案:

答案 0 :(得分:0)

GData已被弃用且与许多Android版本不兼容。

阅读this会有所帮助。

答案 1 :(得分:-1)

我收到了这段代码。看,它可以帮到你

Cursor cursor = cr.query(Uri.parse("content://calendar/events"), new String[]{ "calendar_id", "title", "description", "dtstart", "dtend", "eventLocation" }, null, null, null);         
    //Cursor cursor = cr.query(Uri.parse("content://calendar/calendars"), new String[]{ "_id", "name" }, null, null, null);
    String add = null;
    cursor.moveToFirst();
    String[] CalNames = new String[cursor.getCount()];
    int[] CalIds = new int[cursor.getCount()];
    for (int i = 0; i < CalNames.length; i++) {
        CalIds[i] = cursor.getInt(0);
        CalNames[i] = "Event"+cursor.getInt(0)+": \nTitle: "+ cursor.getString(1)+"\nDescription: "+cursor.getString(2)+"\nStart Date: "+new Date(cursor.getLong(3))+"\nEnd Date : "+new Date(cursor.getLong(4))+"\nLocation : "+cursor.getString(5);
        if(add == null)
            add = CalNames[i];
        else{
            add += CalNames[i];
        }           
        ((TextView)findViewById(R.id.calendars)).setText(add);

        cursor.moveToNext();
    }
    cursor.close();