Before petting someone else's dog, ask the owner for permission. When petting, pet on the under-side of the dog's neck, rather than on top of its head. Keep your hands at your sides. Allow him to sniff you before you reach to pet him. Spend time playing with and caring for your dog.
Pets often guard their food, their babies, and their toys.
A dog's natural instinct is to chase after something that's running from it. Instead, stand still, let the dog sniff you, and continue to be still and quiet till the dog walks away and leaves you alone. Unneutered dogs are generally more likely to bite. Instead, tell an adult about the animal. If a dog shows any signs of aggressiveness toward you, report it to the dogs owner, or to animal control.