I heard that ときどき can only be used in an affirmative sentence, and never in a negative sentence. Is that true?
If anyone could please provide an example of ときどき in a negative sentence, that would be great too!
The nature of the word "sometimes" implies both a positive and negative side to it. Take the following sentence:
Sometimes I go out for a walk.
This means that sometimes you do walk, but implicitly, sometimes you don't. Even though the verb is in the affirmative, the sentence is partly positive and partly negative.
This gives us a little flexibility with the verb, because it will be correct in either the positive or negative. By default, people will usually stick with positive, but occasionally there is a good reason to use negative, such as emphasis on the negativity part. In the link macraf gave in the comments, for example:
Symptom: sometimes doesn't connect
The negative is used with ときどき here to emphasize the fact that is sometimes is not connecting. The affirmative is fine grammatically, but 「時々つながる」doesn't make much sense it context, as doesn't really sound like a real problem for a troubleshooting page.