It is a curious and exciting thing to know that God knows us so well. David makes this claim in this passage and finds comfort in his time of need. The world was against him, he did not know who his friends were.
My mind works like this: “How have I felt like this in the past?” Everytime I question whether the God of the infinite universe could possibly “do business” with someone as finite as I, it causes me to feel as if I have a backstage pass, or I am friends with someone famous. “Where can I go from your Spirit?” asks David “when I make my bed in the valley you are there”. He was comforted to know that God was still with him even in the midst of this persecution. Even after David got angry at God for his present situation. He was consistent, loving, and persistent.