how to fetch data for every 5 seconds?

I making an app that logs battery value every 5 seconds. I am also doing a api get request along with it. these values are added in a csv file. my doubt is how do i make this task run continuously.

Thank you😄
Was this page helpful?