EventResolver extends UrbanAirshipResolver { void trimDatabase(int maxDatabaseSize) { while (getDatabaseSize() > maxDatabaseSize) { String sessionId = getOldestSessionId(); if (UAStringUtil.isEmpty(sessionId)) { break; } Logger.debug("Event database size exceeded. Deleting oldest session: %s", sessionId); int deleted = delete(uri, EventsStorage.Events.COLUMN_NAME_SESSION_ID + " = ?", new String[] { sessionId }); if (deleted > 0) { Logger.debug("EventsStorage - Deleted %s rows with session ID %s", deleted, sessionId); } else { break; } } } EventResolver(@NonNull Context context);  @NonNull
    static final String ASCENDING_SORT_ORDER; }
@Test public void testTrimDatabase() { TestEvent event = new TestEvent("some-id"); eventResolver.insertEvent(event, "OLD"); eventResolver.insertEvent(event, "NEW"); assertEquals(2, eventResolver.getEventCount()); eventResolver.trimDatabase(event.createEventPayload("OLD").length()); assertEquals(1, eventResolver.getEventCount()); eventResolver.trimDatabase(0); assertEquals(0, eventResolver.getEventCount()); }