The new rise in law enforcement searching electronic devices falls in line with the court established practice of allowing officers to search those who they formally contact. This stems from concerns of officer safety and does not limit officers from looking inside something, aka a wallet or phone. Thus your phone is not special property and can be searched for evidence during something as routine as a traffic stop if an officer pulls you out of the car.
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.