David, the prophet

Peter, in his famous speech on the day of Pentecost in Acts 2, demonstrates that Jesus of Nazareth is the Messiah and would rise from the dead. His listeners are Israelites (verses 22 and 36), and he therefore appeals to the Hebrew Scriptures. They had crucified and killed Jesus, but God raised Him:

24 God raises Him up and loosens the pains of death, because it was not possible for Him to be held by it.

Psalms
Peter then quotes Psalm 16, a Psalm of David, to his Jewish listeners and says that this Psalm is about Christ (Hebrew: Messiah) and about His death and resurrection:

25 For David says concerning Him, I have seen the Lord continually before me, before my eyes, for He is at my right hand, so that I will not be moved.
26 Therefore my heart is glad, and my tongue sings for joy. Yes, my flesh also will rest in hope,
27 because you will not abandon my soul to the grave, nor will you allow your righteous one to see decay.
28 You make known to me the ways of life; you will make me rejoice with your countenance.

Christ
This Psalm of David is about the death and resurrection of Christ. These are the words of King David, but they speak essentially about the Son of David. Peter goes on to say that David is dead and has not yet risen. His grave was even among them in those days (Ps. 29). The Psalms are prophetic, and Peter reinforces this:

30 Therefore, being a prophet, and knowing that God had sworn with an oath to him to set on his throne someone from the fruit of his loins,
31 seeing this beforehand, he spoke of the resurrection of Christ, that he would neither be abandoned in the grave nor see corruption.

prophet
David was a prophet, and he knew this. From David, from his descendants, would come the Messiah: the Son of David. David points forward to Him who was to come. David’s words in the Psalms are, in reality, the words of the Son of David.

type of the Son
In his name, too, David points us to the Son of David. His name means Beloved. At the beginning of the Lord’s public ministry, He is identified by the Father himself: And behold, a voice from heaven said, This is my beloved Son, in whom I am well pleased (Matt. 3:17).

histories
The stories we find in the Bible about David are similarly prophetic in nature. David had already been anointed king, but was not yet on the throne. He was fleeing from Saul and hid in the cave of Adullam. There he gathered a people around him (1 Sam. 22:1-2).
In all of this, David is a foreshadow, a type, of the Messiah (=Anointed One) in our time. Christ is also not yet seated on the throne. He is now hidden in heaven, and in this time He is gathering His ecclesia, His called-out church.

David on the throne, subduing all his enemies, is a picture of Christ who will in the future establish His Kingdom, reign on the throne in Jerusalem, and subdue all nations.