That is why it is always best to say to any law enforcement officer:
1: I do not consent to a search.
"if in your house keep the door locked unless they have a search warrant"
"If in your car keep the door locked unless they ask you to get out of the vehicle. When exiting the vehicle turn off the car, remove the key to the car and lock the car door when you exit the car"
2: Ask am I being detained?
"If no - leave the area ASAP."
"if yes - refer to #3"
3: I would like to have an attorney present before I answer any questions you have"
"If they continue to question you - ask them if they are intentionally continuing questioning after you have expressed your request to have a attorney present?"
DO NOT SAY ANYTHING ELSE!
DO NOT RESIST IN ANY WAY!
This gives your lawyer the best chance of getting the case against you dismissed.
Below is an attorney and a police officer explaining it much better than I can.