Modern mobile devices (smart phones, wearable devices, and smart vehicles) have greater resources (communication, computation, and sensing) than before, and these resources are not always fully utilized by device users. Therefore, mobile devices, from time to time, encounter other devices that could provide resources to them. Because the amount of such resources has increased with the number of mobile devices, researchers have begun to consider making use of these resources, located at the 'edge' of mobile networks, to increase the scalability of future information networks. This has led to a cooperation based architecture of mobile cloud computing (MCC). This paper reports the concept and design of a resource sharing mechanism that utilizes resources in mobile devices through opportunistic contacts between them. Theoretical models and formal definitions of problems are presented. The efficiency of the proposed mechanism is validated through simulation.