Never consent to a search. If police try to search your house, car, backpack, pockets, etc. say the Magic Words: "I do not consent to this search." This may not stop them from forcing their way in and searching anyway, but if they search you illegally, they probably won't be able to use the evidence against you in court. You have nothing to lose from refusing to consent to a search and lots to gain. Do not physically resist law enforcement officers when they are trying to search, because you could get hurt and/or charged with resisting arrest or assault and battery. Just keep repeating the Magic Words so that the officers and all witnesses know that this is your stance.
Be careful about casual consent. That is, if law enforcement officers stop you and you get out of the car but don't close the door, they might search the car and claim that they thought you were indicating consent by leaving the door ajar. Also, if you say, "I'd rather you didn't search," they can claim that you were reluctantly giving them permission to search. Always just say the Magic Words: "I do not consent to this search."