Regardless of what you’re protesting, if you head out to exercise your First Amendment rights, you will probably have a cellphone with you. You might be planning to take photos/videos with it or use it to contact people. But you might also have it just because you always have it. And if you have a cellphone with you at a protest, it’s good to know where you stand if law enforcement agents make demands related to the device.

The question of whether police could search a cellphone without a warrant during an arrest used to be somewhat ambiguous. But in June the Supreme Court ruled unanimously in Riley v. California that police do need a warrant. This is good news for protesters, but in a heated moment law enforcement could still bend these rules.

As the Electronic Frontier Foundation points out, “Increasingly, we keep our most sensitive communications and personal information on our cell phones,” and bringing one to a protest should be a carefully considered decision. EFF suggests bringing a temporary device to rallies if possible, so you still have access to all the tools you want without exposing your digital footprint.

If this isn’t an option, though, or you realize too late that you’ve brought your device without first making a plan, you can add a key code/password to your phone and set your phone’s home screen to lock very quickly when no one is using it. Don’t forget that a fingerprint lock alone may not be enough to secure your phone, because you could be compelled to use your finger to unlock it. Also, messaging with friends on a service that uses end-to-end encryption (like Wickr or now WhatsApp) can help keep the content of messages away from prying eyes.

While at the protest, you are allowed to photograph or take video so long as you are in a public space. On private property, rules may be slightly different, but in general law enforcement can’t view or delete media on your smartphone without your permission. Uploading media to a cloud service, live stream, or social network as you capture it is one measure you can take to make sure what you’re recording gets out there, and isn’t tampered with by law enforcement or anyone else.

If you are arrested, you have the right to remain silent and request your attorney. If police ask to view the contents of your phone without a warrant, you can decline, and you can refuse to provide your passcode. EFF notes, though, that, “just because the police cannot compel you to give up your password, that doesn’t mean that they can’t pressure you.” Having a temporary device and uploading everything as you capture it can make these situations a little less tense.

As the American Civil Liberties Union points out, Riley v. California addresses cellphones specifically, so it’s possible that other devices like standalone cameras could be held to a different standard. The ACLU says its interpretation is that “the constitution broadly prevents warrantless searches of your digital data,” though.

Protesting is a valuable expression of free speech in a democracy, but digital devices complicate it in a number of ways. Having a cellphone at a rally shouldn’t expose you to additional risk of privacy invasion, though. And if you give careful thought to protecting yourself, you can minimize this risk.