The only defense against such searches is to password protect your smartphone. Law enforcement cannot compel you to reveal any passwords (4th amendment protects you from self incrimination) and thus your information can remain safe on your phone. The same is true if you store your phone off of your person in your vehicle when you are flagged for traffic stops. While you might be thinking if you have nothing to hide, why not just let them search my phone, if you phone has anything incriminating it can be used as justification to get full warrants to search your property. Even a law abiding citizen could have unwittingly broken a law and a search of your phone might help produce evidence that can be used against you.
If you would like to know more, check out Ars Technica's excellent in depth look at the rising trend of cell phone searches. Their article details the legal aspects and history of searches of electronic devices. Also please bear in mind this is in no way legal advice, be careful out there.