David literally ran for his life on more than one occasion. In 1 Samuel 19, he ran from Saul after the unhinged king tried to kill him four times. David stayed in hiding from Saul for the next 10 chapters. Later on, in 2 Samuel 15, David ran away from Jerusalem to as his son, Absalom, made a claim to the throne.
The inscription given to Psalm 3 explains that it was written around the time David fled from his son, Absalom. Even though the inscription is not inspired by the Holy Spirit, it gives modern readers a starting place to evaluate the king’s comments. David had the right to speak about these issues because he has seen the worst kinds of battles.
This Psalm is sometimes described as a morning prayer of trust in God. In four short stanzas, David ran from his enemies and ran to God for help. Instead of focusing on threat that rose up all around him, David focused on the protection that God would provide. His faith in God drove Him to trust in the One who is a “shield” around His people.

Very good! Thankful He is our sword and shield! Thank you!