This paper presents Contory, a middleware specifically deployed to support provisioning of context information on mobile devices such as smart phones. Contory integrates multiple strategies for context provisioning, namely internal sensors-based, external infrastructure-based, and distributed provisioning in ad hoc networks. Applications can query Contory about context items of different types, using a declarative query language which features on-demand, periodic, and event-based context queries. Contory allows applications to utilize different provisioning mechanisms depending on resource availability and presence of external infrastructures. This paper illustrates our approach along with its design and implementation on smart phones.