This quote by John Calvin comes from Day 149 in the devotional Heart Aflame:
It is apparent that David never allowed himself to be so far overcome by his trials, as to cease lifting up his prayer to heaven, and even resting, with a firm and constant faith, upon the divine promises. Apt as we are, when assaulted by the very slightest trials, to lose the comfort of any knowledge of God we may previously have possessed, it is necessary that we should notice this, and learn, by his example, to struggle to maintain our confidence under the worst troubles that can befall us. He does more than simply pray; he sets the Lord before him as his God, that he may throw all his cares unhesitatingly upon him, deserted as he was of man, and a poor outcast in the waste and howling wilderness. His faith, shown in this persuasion of the favour and help of God, had the effect of exciting him to constant and vehement prayer for the grace which he expected.
Calvin, John. (1999). Heart Aflame Daily Readings from Calvin on the Psalms. Phillipsburg, NJ: P&R Publishing Company.