collecting data in background

I'd like to write app/widget that collecting some data all the time even if it doesn't run in foreground.

I know that I can do one shot from app to background but how it repeat if app is not in foreground?

Can I call registerForTemporalEvent from onTemporalEvent to repeat reading data in 5 minutes?

Can background use Storage.setValue to save data for app?