Java Code Examples for android.database.DatabaseUtils#cursorLongToContentValuesIfPresent()

The following examples show how to use android.database.DatabaseUtils#cursorLongToContentValuesIfPresent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalendarContract.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
    // we expect the cursor is already at the row we need to read from
    final long calendarId = cursor.getLong(cursor.getColumnIndexOrThrow(_ID));

    // Create the content value
    ContentValues cv = new ContentValues();
    cv.put(_ID, calendarId);

    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);

    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID);
    DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, MUTATORS);

    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC1);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC2);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC3);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC4);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC5);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC6);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC7);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC8);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC9);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC10);

    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Calendars.NAME);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
            Calendars.CALENDAR_DISPLAY_NAME);
    DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
            Calendars.CALENDAR_COLOR);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
            Calendars.CALENDAR_COLOR_KEY);
    DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, CALENDAR_ACCESS_LEVEL);
    DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, VISIBLE);
    DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SYNC_EVENTS);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
            Calendars.CALENDAR_LOCATION);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CALENDAR_TIME_ZONE);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
            Calendars.OWNER_ACCOUNT);
    DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
            Calendars.CAN_ORGANIZER_RESPOND);
    DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
            Calendars.CAN_MODIFY_TIME_ZONE);
    DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
            Calendars.MAX_REMINDERS);
    DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv,
            Calendars.CAN_PARTIALLY_UPDATE);
    DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
            Calendars.ALLOWED_REMINDERS);

    DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED);

    // Create the Entity from the ContentValue
    Entity entity = new Entity(cv);

    // Set cursor to next row
    cursor.moveToNext();

    // Return the created Entity
    return entity;
}