David was a man who knew how to look deeply within. He was flawed but understood that he wanted the love of friendship to dwell within him. In order for this to take place, he had to understand his mission. David is expressing his knowledge of the fact that God has penetrated to the core of his being and examined his character intently, and He understands David better than anyone else ever could.
Psalm. 139:1 O LORD, thou hast searched me, and known me.
The word for known indicates the results of that examination; David was God’s “familiar friend.” I think that truth can be verified with scripture that identifies David as a man after God’s own heart.