By this I know that you delight in me: my enemy will not shout in triumph over me. But you have upheld me because of my integrity, and set me in your presence forever.
The confidence in God is strong in this psalm. It is based on obedience to God (see 41:1 in which David knows he has cared for the poor and needy like God does). The relationship that David had with God was everything to him. It was really the summary of his life and his confidence for the future.
Things did not always go easy for David. He had his share of enemies. Both before and after his rise to Israel's throne, David had opposition that wanted him dead. These weren't just political foes... they were personal ones. But the king of Israel confidently trusted God that his enemies would not shout in triumph over him. God would guard the king because of his integrity.
David also had a confidence about the future that was bound in his relationship with God. He knew he would be in God's presence forever. He saw a relationship with God guiding his present and his future. Integrity and faithfulness to God's Word led him in the present. God's commitment to him would protect him for the future. All times were in the presence and control of God. That is security!