There are really a few sub-questions: Is it legal, and are the results admissible as evidence?
Whether or not it's legal depends on the circumstances. There are many cases in which the police can search something, e.g., if they believe it's critical to prevent an immediate threat. Whether or not it's admissible is more thorny, and something that's still being fought out in the courts. (google: warrantless cell phone search admissible)
There are really a few sub-questions: Is it legal, and are the results admissible as evidence?
Whether or not it's legal depends on the circumstances. There are many cases in which the police can search something, e.g., if they believe it's critical to prevent an immediate threat. Whether or not it's admissible is more thorny, and something that's still being fought out in the courts. (google: warrantless cell phone search admissible)