Class TrackerDatasource


  • public final class TrackerDatasource
    extends java.lang.Object
    Tracker datasource. Wraps SQLite queries (DAO).
    • Constructor Detail

      • TrackerDatasource

        public TrackerDatasource​(android.content.Context context)
                          throws android.database.sqlite.SQLiteException
        Throws:
        android.database.sqlite.SQLiteException
    • Method Detail

      • getAllEvents

        protected java.util.List<Event> getAllEvents()
        Retrieve all events in DB (for test purpose)
        Returns:
      • clearDB

        public void clearDB()
        Clear all content
      • addEvent

        public boolean addEvent​(Event event)
        Add an event to the database
        Parameters:
        event - Event to add
      • extractEventsToSend

        public java.util.List<Event> extractEventsToSend​(int limit)
        Extract a set of events and set their state to Event.State.SENDING
        Parameters:
        limit -
        Returns:
        a list of events (can be empty on error)
      • updateEventsToNew

        public boolean updateEventsToNew​(java.lang.String[] eventIDs)
        Set the State to NEW for the given events ids
        Parameters:
        eventIDs -
        Returns:
        true on success, false otherwise
      • updateEventsToOld

        public boolean updateEventsToOld​(java.lang.String[] eventIDs)
        Set the State to OLD for the given events ids
        Parameters:
        eventIDs -
        Returns:
        true on success, false otherwise
      • deleteEvents

        public int deleteEvents​(java.lang.String[] eventIDs)
        Delete events by their ID
        Parameters:
        eventIDs - IDs of the events to delete
        Returns:
        int number of raws deleted (-1 on error)
      • deleteOverflowEvents

        public int deleteOverflowEvents​(int limit)
        Delete events if there's too much in DB
        Parameters:
        limit - maximum number of events wanted
        Returns:
        the number of events deleted
      • close

        public void close()
        Close the datasource. You should not make any other call to this datasource once this has been called.
      • resetEventStatus

        public boolean resetEventStatus()
        Reset all event to Event.State.OLD state
        Returns: