I know that sugar causes cavity and fruits have sugar... But are they the same sugar that causes cavity?

Yes. The sugars feed the bacteria in your mouth to produce acids that destroy at he teeth. Fruits also have acids that will erode teeth and can cause cavities. So be careful with your diet. Do not snack or browse all day long.