The directed movement of nucleic acids, single or double-stranded polynucleotides involved in the storage, transmission and transfer of genetic information, into, out of or within a cell, or between cells, by means of some agent such as a transporter or pore.