An emerging model in associative learning and memory in Drosophila, suggests that dopaminergic neurons (DANs) modulate the synaptic output of mushroom body neurons driving the appropriate behavior (approaching or avoidance). However, whether DANs are involved in contextual memory is unclear. Here, we examined the role of dopaminergic neurons in contextual memory in freely behaving flies. We blocked neuronal activity of specifics subset of DANs by using the thermosensitive allele Shits1. We found that contextual memory is promoted by two kinds of DANs. The first kind corresponds to those DANs that prevented habituation during training in the contextual learning (PPM2). The second kind of DANs corresponds to neurons that were not involved in the contextual learning (PAL). Therefore, suggesting that the second kind of DANs are not involved in sensory or motor activity during the assay, but specifically participate in memory. Interestingly, there are no DANs preventing contextual memory, as it was found for learning. Contextual memory required synaptic output from a smaller number of dopaminergic neurons than that required for contextual learning. Of note, DANs involved in contextual memory are not the same neurons implicated in learning as it is reported in associative learning.