In general the preterite is used when something has been completed. If an action has a definite start and end then you should be using the preterite, this can be both if it is something that happened once or if it is something that was repeated a specific number of times.
For example - Ayer, fue al cine. (Yesterday, he went to the cinema)
Me llamó dos veces. (He called me twice)
The imperfect is used when you don't have a definite end point. This could be something that happened generally in the past or something that has not yet been completed. It is also used often as a way of setting up the use of another past tense.
For example - Cuando era niño, tuve un fútbol. (When I was a child, I had a football)
Yo estaba hablando cuando tosía. (I was talking when he coughed)