"If I regard iniquity in my heart, the Lord will not hear me:" -Psalms 66:18, KJV.
We cannot expect to live in sin and have God answer our prayers. Sin creates a barrier between us and God, and He cannot be around sin. It would be like cheating on your spouse and expecting them to still treat you the same way. It's pure foolishness.