HIV spreads through unprotected sex with infected person or by sharing of needles and also from mother to baby by birth or through breast feeding.
So, even if you don’t have unprotected Vaginal / anal / oral sex, if you happen to share needles, yes, you may get infected.