Answered prayer is based on having a covenant relationship with the Lord, as all Christians do. The promises of that covenant are expressed in the Scriptures. From God’s point of view, those promises are the legal provisions which He has supplied for His children. They define the covenant relationship and are inseparable from it.
Covenant relationship is the background for understanding 1 Peter 3:12, which says, “The eyes of the Lord watch over those who do right, and his ears are open to their prayers. But the Lord turns his face against those who do evil.” John 9:31 says, “We know that God doesn’t listen to sinners, but he is ready to hear those who worship him and do his will.”
Because of this, we know that any time it seems God is answering the prayers of a sinner, it’s actually not because of that sinner’s prayers, but because of the intercession of Christians on their behalf (Isaiah 59:16-21; Ezekiel 22:30-31).
That said, based on this principle, there is a prayer that God still hears when someone who doesn’t know Him prays. It is the prayer in which the sinner asks for salvation through Jesus Christ. The Lord always hears those who call on Him (Romans 10:13)!