The psalmist rejoiced over God's character and His blessings to him (vv. 30-45), and he vowed to continue to praise Him forever (vv. 46-50). The purpose of the psalm is praise, not boasting.
18:30-31 God's way is perfect, and His Word is trustworthy. He is the only true God, a reliable defense and a solid foundation for His people (cf. Deut. 32:4, 31).
18:32-42 We should probably read verse 32 with verse 33 rather than with verse 31. David gave the Lord credit for enabling him to be a strong and effective warrior. God was responsible for David's successes in battle.
18:43-45 God had even extended David's victories beyond the borders of Israel. The king had been able to subdue other kingdoms and bring them under his control. David's greatest Son will be able to echo these sentiments when He rules on earth during the Millennium.
18:46-50 Only a living God could do all this for David. Consequently the king promised to praise Him among those who did not know Yahweh. God's deliverance and His loyal love are the final gifts David mentioned as those he treasured above all others. He was confident because of what God had done for him that Yahweh would prove faithful and deliver David's descendents as He had promised as well (2 Sam. 7).
God's people should always acknowledge the magnificent multifaceted character of our God. We should also recount His awesome acts of deliverance for us. Furthermore we should continue to rely on His future faithfulness in view of who He is and what He has done for us.