The lack of continuous connectivity and a complete path from source to destination makes node communication quite difficult in Delay-Tolerant Networks (DTNs). Most studies focus on routing problems in idealized network environments without considering social properties. Communication devices are carried by individuals in many DTNs; therefore, DTNs are unique social networks to some extent. To design efficient routing protocols for DTNs, it is important to analyze their social properties. In this paper, a more accurate and comprehensive metric for detecting the quality of the relationships between nodes is proposed, by considering the contact time, contact frequency, and contact regularity. An overlapping hierarchical community detection method is designed based on this new metric, and a tree structure is built. Furthermore, we exploit the overlapping community structure and the tree structure to provide message-forwarding paths from the source node to the destination node. The simulation results show that our Routing method based on Overlapping hierarchical Community Detection (ROCD) achieves better delivery rate than SimBet and Bubble Rap, the classic routing protocols, without affecting the average delay.