James 4:7 KJV
Submit yourselves therefore to God. Resist the devil, and he will flee from you.
Being submitted to God means we are submitted to His ways. Before we can have power from God to resist the devil, we need to make sure we are walking in and living out the teachings of the Bible in our everyday life.
We must also repent of things in our life which displease God. Then when the enemy comes to attack us, we will be in good standing before God and there will not be any sin to hinder our connection with Jesus.
When the devil attacks, we will be able to resist and defeat Him through prayers, fasting, and standing on the authority of scripture (this is how Jesus defeated satan in Mathew.
The verse above is very important because many times out of ignorance, a Christian can go into spiritual warfare with sin still in his or her life, and such a person will not be able to gain victory. The devil will not flee from such a person’s life, because they have given an entryway to satan.
Walking in righteousness is one of the greatest defense systems against the devil, therefore we should all seek to live right before God.
And if there is any sin we struggle with, we do not need to be discouraged because The Lord can help us overcome it by praying and/or fasting about it.
God bless you