Of Place for Prayer
But how “in every place,” since we are prohibited (from praying) in public? In every place, he means, which opportunity or even necessity, may have rendered suitable: for that which was done by the apostles (who, in jail, in the audience of the prisoners, “began praying and singing to God”) is not considered to have been done contrary to the precept; nor yet that which was done by Paul, who in the ship, in presence of all, “made thanksgiving to God.”
Source: On Prayer (New Advent)