Smartphones with various embedded sensors and wirelessly connected external sensors will enable new applications across a wide variety of domains. Continuous or long-term sensing, processing, and communication of sensor data using smartphones will consume a significant amount of energy of the resource-constrained smartphones. Compression techniques, including predictive coding (PC) and compressed sensing (CS), are promising ways of minimizing energy consumption. A number of compression-based proposals are available to improve the energy efficiency in smartphones. Most of these proposals are sensor and application-specific, and their sampling rates may not be adaptive. This article proposes an energy efficient data gathering (DG) framework based on compression techniques, in particular as a component of a middleware for the smartphones. The framework adaptively selects the best possible compression technique (CT) for a sensor DG from a list of CTs, using the application's requirements and contexts. This work also presents a CS-based PC (CPC) to minimize the learning cost in PC. The framework includes the CPC along with other CTs and exploits context-aware adaptive sampling rate to improve energy efficiency. An initial evaluation of the framework using two real datasets highlights the potential of it and the CPC.