This refers to a specific historical event that the Hebrews knew well. Alternate translation: "when he was in Abimelek's house" or "when he was Abimelek's prisoner" (See: [[rc://en/ta/man/jit/figs-explicit]])
Here "in my mouth" refers to David speaking about Yahweh. Alternate translation: "I will always praise him out loud" (See: [[rc://en/ta/man/jit/figs-metonymy]])