16 I will instruct you of that which is written, that the Spirit is not at every time found with those that receive it. For thus it is written about Saul, that the Holy Spirit, which he received when he was anointed, departed from him, because he grieved it, and God sent to him instead of it a vexing spirit. And whenever he was afflicted by the evil spirit, David used to play upon the harp, and the Holy Spirit, which David received when he was anointed, would come, and the evil spirit that was vexing Saul, would flee from before it.
So the Holy Spirit that David received was not found with him at every time. As long as he was playing the harp, then it used to come. For had it been with him always, it would not have allowed him to sin with the wife of Uriah. For when he was praying about his sins, and was confessing his offenses before God, he said thus:— Take not Your holy spirit from me. Also concerning Elisha it is thus written, that, while he played upon his harp, then the spirit came to him and he prophesied and said:— Thus says the Lord, you shall not see wind nor rain, yet this valley shall be made many pits. And also when the Shunamite came to him because of her son that was dead, he said thus to her:— The Lord hid it from me and did cause me not to know it. Yet, when the King of Israel sent against him to slay him, the Spirit informed him before the messenger came upon him, and he said:— Lo!
This son of iniquity has sent to take away my head</em>. And again he made known about the abundance that came about in Samaria the day after. And again the Spirit informed him when Gehazi stole the silver and concealed it.
Source: Demonstrations (New Advent)