The lifetime of a sensor network is very important, especially in data-intensive applications, such as military monitoring, the internet of things, and audio/video surveillance, since battery capacity is always limited. Accordingly, the deployments of relay nodes and the configuration of mobile relays in sensor networks have been extensively investigated. Since mobile relays support movement, the lifetime of a sensor network can be adaptively extended in a manner that depends on its current state. This work develops a relay configuration, called ShareEnergy strategy, which tries to prolong the lifetime of sensor networks using mobile relay technology. The greatest difference between the ShareEnergy strategy and other strategies is that the ShareEnergy strategy focuses on prolonging the lifetime of sensor networks while others try to minimize the power consumption of data transmission. The ShareEnergy applies an equation that combines the lifetime and the energy parameters to calculate new locations of the mobile relay that maximally prolong the lifetime of the sensor network. Our simulation results show that the the ShareEnergy can reduce the power consumption of data transmissions in the sensor network by 17% compared to the relays without movements. Moreover, compared to other solutions, the ShareEnergy increase the lifetime of the sensor networks by 38%.