  Spatiotemporal context is crucial in modern mobile applications that utilize
increasing amounts of context to better predict events and user behaviors,
requiring rich records of users' or devices' spatiotemporal histories.
Maintaining these rich histories requires frequent sampling and indexed storage
of spatiotemporal data that pushes the limits of resource-constrained mobile
devices. Today's apps offload processing and storing contextual information,
but this increases response time, often relies on the user's data connection,
and runs the very real risk of revealing sensitive information. In this paper
we motivate the feasibility of on-loading large amounts of context and
introduce PACO (Programming Abstraction for Contextual On-loading), an
architecture for on-loading data that optimizes for location and time while
allowing flexibility in storing additional context. The PACO API's innovations
enable on-loading very dense traces of information, even given devices'
resource constraints. Using real-world traces and our implementation for
Android, we demonstrate that PACO can support expressive application queries
entirely on-device. Our quantitative evaluation assesses PACO's energy
consumption, execution time, and spatiotemporal query accuracy. Further, PACO
facilitates unified contextual reasoning across multiple applications and also
supports user-controlled release of contextual data to other devices or the
cloud; we demonstrate these assets through a proof-of-concept case study.
