Utilizing device-to-device (D2D) connections among mobile devices is promising to meet the increasing throughput demand over cellular links. In particular, when mobile devices are in close proximity of each other and are interested in the same content, D2D connections such as Wi-Fi Direct can be opportunistically used to construct a cooperative (and jointly operating) cellular and D2D networking system. However, it is crucial to understand, quantify, and exploit the potential of network coding for cooperating mobile devices in the joint cellular and D2D setup. In this paper, we consider this problem, and (i) develop a network coding framework, namely NCMI, for cooperative mobile devices in the joint cellular and D2D setup, where cellular and D2D link capacities are the same, and (ii) characterize the performance of the proposed network coding framework, where we use packet completion time, which is the number of transmission slots to recover all packets, as a performance metric. We demonstrate the benefits of our network coding framework through simulations.