Indoor localization has become a popular topic in recent years. While self-contained pedestrian dead reckoning (PDR) systems can be conveniently implemented on a smartphone with built-in inertial sensors for indoor localization, the error of the estimated position for a PDR system can accumulate quickly and results in an unacceptable position accuracy. To address this issue, we propose the collaborative pedestrian dead reckoning (CPDR) system. The main idea of the CPDR system is when users are near to each other, we can leverage the proximity information to improve their estimated positions by means of the opportunistic Kalman filter. In addition, the backward correction scheme is used to improve the accuracy of user's trajectory. To evaluate the CPDR system, a prototype is implemented on Apple's iPhone 5. The experiment results show that the CPDR system achieves a better position accuracy than the raw PDR system.