Store uncooked rice in a sealed container in your pantry.
White rice should last indefinitely if stored correctly, while brown rice may go rancid (due to the oils in its outer hull) so should be eaten within 12 months.
Store cooked rice in the fridge and eat within a few days, or freeze it and eat it within a couple of months.
To ensure your leftover rice is safe to eat, cool it as quickly as possible after cooking. To cool your rice quickly, take it out of the pot or rice cooker as soon as you can and spread your rice on a tray or place it in shallow containers.