Luke 1:6

And they were both righteous before God, walking in all the commandments and ordinances of the Lord, blameless.

Acts 13:22

and having deposed him, he raised up to them David for a king; to whom witnessing he also said, I have found David the son of Jesse, a man according to my own heart, who will do all my wishes.

Acts 13:36

For David, indeed having served his own generation according to the will of God, went to sleep, and did see corruption:

Treasury of Scripture Knowledge

Summary

Because David did that which was right in the eyes of the LORD, and turned not aside from any thing that he commanded him all the days of his life, save only in the matter of Uriah the Hittite.

Bible References

David

Luke 1:6
And they were both righteous before God, walking in all the commandments and ordinances of the Lord, blameless.
Acts 13:22
and having deposed him, he raised up to them David for a king; to whom witnessing he also said, I have found David the son of Jesse, a man according to my own heart, who will do all my wishes.