コード例 #1
0
  private Entity setupTestEventEntity(String organizer, String attendee, String title) {
    // Create an Entity for an Event
    ContentValues entityValues = new ContentValues();
    Entity entity = new Entity(entityValues);

    // Set up values for the Event
    String location = "Meeting Location";

    // Fill in times, location, title, and organizer
    entityValues.put(
        "DTSTAMP",
        CalendarUtilities.convertEmailDateTimeToCalendarDateTime("2010-04-05T14:30:51Z"));
    entityValues.put(Events.DTSTART, Utility.parseEmailDateTimeToMillis("2010-04-12T18:30:00Z"));
    entityValues.put(Events.DTEND, Utility.parseEmailDateTimeToMillis("2010-04-12T19:30:00Z"));
    entityValues.put(Events.EVENT_LOCATION, location);
    entityValues.put(Events.TITLE, title);
    entityValues.put(Events.ORGANIZER, organizer);
    entityValues.put(Events._SYNC_DATA, "31415926535");

    // Add the attendee
    ContentValues attendeeValues = new ContentValues();
    attendeeValues.put(Attendees.ATTENDEE_RELATIONSHIP, Attendees.RELATIONSHIP_ATTENDEE);
    attendeeValues.put(Attendees.ATTENDEE_EMAIL, attendee);
    entity.addSubValue(Attendees.CONTENT_URI, attendeeValues);

    // Add the organizer
    ContentValues organizerValues = new ContentValues();
    organizerValues.put(Attendees.ATTENDEE_RELATIONSHIP, Attendees.RELATIONSHIP_ORGANIZER);
    organizerValues.put(Attendees.ATTENDEE_EMAIL, organizer);
    entity.addSubValue(Attendees.CONTENT_URI, organizerValues);
    return entity;
  }
コード例 #2
0
  /** Build an {@link Entity} with the requested set of phone numbers. */
  protected EntityDelta getEntity(Long existingId, ContentValues... entries) {
    final ContentValues contact = new ContentValues();
    if (existingId != null) {
      contact.put(RawContacts._ID, existingId);
    }
    contact.put(RawContacts.ACCOUNT_NAME, TEST_ACCOUNT_NAME);
    contact.put(RawContacts.ACCOUNT_TYPE, TEST_ACCOUNT_TYPE);

    final Entity before = new Entity(contact);
    for (ContentValues values : entries) {
      before.addSubValue(Data.CONTENT_URI, values);
    }
    return EntityDelta.fromBefore(before);
  }