What to do if a police officer asks you ANYTHING:
You: "Am I being charged or otherwise detained?"
If the officer has no charge against you or isn't detaining you, you have no other business with the officer. NEVER talk to a police officer other than the above line. If they reply "yes" to the above line say NOTHING after that.
Police do NOT have the right to ask for ID without a charge, regardless of the situation, it's your right.
They also do NOT have the right to search your bags/trunk/whatever WITHOUT A WARRANT. So if you're at the beach and they wanna search your bag for drugs/alcohol ask for a warrant, provided you weren't drinking/doing drugs where they could see you.
Hopefully this helps, just remember that you do have rights as an innocent person.