"A new danger now presented itself. Doeg, the chief of Saul's herdsmen, who had professed the faith of the Hebrews, was now paying his vows in the place of worship. At sight of this man David determined to make haste to secure another place of refuge, and to obtain some weapon with which to defend himself if defense should become necessary. He asked Ahimelech for a sword, and was told that he had none except the sword of Goliath, which had been kept as a relic in the tabernacle. David replied, “There is none like that; give it me.” His courage revived as he grasped the sword that he had once used in destroying the champion of the Philistines. PP 656.1"
"And the priest said, The sword of Goliath the Philistine, whom thou slewest in the valley of Elah, behold, it is here wrapped in a cloth behind the ephod: if thou wilt take that, take it: for there is no other save that here. And David said, There is none like that; give it me."
The EGW passage directly quotes and elaborates on the exchange between David and Ahimelech regarding the sword of Goliath, as described in 1 Samuel 21:9.
"David fled to Achish, the king of Gath; for he felt that there was more safety in the midst of the enemies of his people than in the dominions of Saul. But it was reported to Achish that David was the man who had slain the Philistine champion years before; and now he who had sought refuge with the foes of Israel found himself in great peril. But, feigning madness, he deceived his enemies and thus made his escape. PP 656.2"
"And David arose, and fled that day for fear of Saul, and went to Achish the king of Gath."
The EGW passage recounts David's flight to Achish, king of Gath, as described in 1 Samuel 21:10, and expands on the circumstances surrounding it.
"The first error of David was his distrust of God at Nob, and his second mistake was his deception before Achish. David had displayed noble traits of character, and his moral worth had won him favor with the people; but as trial came upon him, his faith was shaken, and human weakness appeared. He saw in every man a spy and a betrayer. In a great emergency David had looked up to God with a steady eye of faith, and had vanquished the Philistine giant. He believed in God, he went in His name. But as he had been hunted and persecuted, perplexity and distress had nearly hidden his heavenly Father from his sight. PP 656.3"
"When my spirit was overwhelmed within me, then thou knewest my path. In the way wherein I walked have they privily laid a snare for me."
The EGW passage describes David's feelings of being hunted and persecuted, which parallels the sentiments expressed in Psalm 142:3 about feeling overwhelmed and ensnared. While not a direct quote, the thematic connection is present.