i think eventID.add(cursor.getLong(0)); this code will fetch you "calendar_id" not the unique id for event
Thanks RK On Fri, Aug 24, 2012 at 2:51 PM, vinay kumar <[email protected]> wrote: > Hi, > > You can use content resolver to get the event_ID and event_Details as well > please check the following code. > > > public class MyCalendar { > > static Cursor cursor; > public static ArrayList<Long> eventID = new ArrayList<Long>(); > public static ArrayList<String> nameOfEvent = new ArrayList<String>(); > public static ArrayList<String> startDates = new ArrayList<String>(); > public static ArrayList<String> endDates = new ArrayList<String>(); > public static ArrayList<String> descriptions = new ArrayList<String>(); > public static ArrayList<String> location = new ArrayList<String>(); > > public static void readCalendar(Context context) { > eventID.clear(); > nameOfEvent.clear(); > startDates.clear(); > endDates.clear(); > descriptions.clear(); > location.clear(); > ContentResolver contentResolver = context.getContentResolver(); > > // Fetch a list of all calendars synced with the device, their > display > // names and whether the > // user has them selected for display. > > cursor = contentResolver > .query(Uri.parse("content://com.android.calendar/events"), > new String[] { "calendar_id", "title", > "description", > "dtstart", "dtend", "eventLocation" }, > null, > null, null); > > cursor.moveToFirst(); > // fetching calendars name > String CNames[] = new String[cursor.getCount()]; > > // fetching calendars id > nameOfEvent.clear(); > startDates.clear(); > endDates.clear(); > descriptions.clear(); > location.clear(); > for (int i = 0; i < CNames.length; i++) { > > eventID.add(cursor.getLong(0)); > nameOfEvent.add(cursor.getString(1)); > if (cursor.getString(2) != null) { > descriptions.add(cursor.getString(2)); > } else { > descriptions.add(""); > } > startDates.add(getDate(Long.parseLong(cursor.getString(3)))); > endDates.add(getDate(Long.parseLong(cursor.getString(4)))); > > if (cursor.getString(5) != null) { > location.add(cursor.getString(5)); > } else { > location.add(""); > } > > CNames[i] = cursor.getString(1); > cursor.moveToNext(); > > } > // printData(); > } > > public static String getDate(long milliSeconds) { > SimpleDateFormat formatter = new SimpleDateFormat( > "dd/MM/yyyy hh:mm:ss a"); > Calendar calendar = Calendar.getInstance(); > calendar.setTimeInMillis(milliSeconds); > return formatter.format(calendar.getTime()); > } > > > > On Fri, Aug 24, 2012 at 2:33 PM, Rahul Kaushik > <[email protected]>wrote: > >> HI, >> >> How to get Unique ID for EventID In android Calender Event after >> insertion of an event??? >> >> Thanks >> RK >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

