Not getting distracted while studying (or any other activity) is the result of three factors: eliminating distractions, being productive and having a purpose.
The first one is obvious - if you don’t want to get distracted, minimize the most common distractions.
Close the door to your room or diplomatically tell your roommates you absolutely can’t be disturbed while studying.
Throw your smartphone out of the window (the answerer of this question can’t be liable for his advice and will not cover any financial or material damage that his advice may cause).
Use apps like StayFocusd (for Chrome) to block Facebook and other social networks during certain times of the day. It’s amazing how we unconsciously visit those websites and don’t even realize it.
Listen to calm-ish music so that you don’t get too pumped up and unfocused.