开发者

How to get saved reminders in android in my application

开发者 https://www.devze.com 2023-03-27 05:55 出处:网络
I am trying to develop an application for android, In which I need to get all the calender entries(Re开发者_JAVA技巧minders), saved in the phone calendar, How can I get them? And Can I do it on androi

I am trying to develop an application for android, In which I need to get all the calender entries(Re开发者_JAVA技巧minders), saved in the phone calendar, How can I get them? And Can I do it on android emulator??


GData is both deprecated and not compatible with many Android versions.

Reading this will help.


I got this code.See, it may help you

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

精彩评论

暂无评论...
验证码 换一张
取 消