-1

enter image description here

This is where I wanted to record, every second was being recorded. But I want data to be added every 5 minutes

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95
  • You might want to make your question about one problem. Are you struggling with repeating logic every 5 minutes, running background tasks, using SQLite, etc.? – Henry Twist Apr 02 '21 at 13:38

1 Answers1

0

You can use RxJava to accomplish this task in a couple of seconds.

and use these dependencies:

 implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.0.1'



 Disposable  disposable = Observable.interval(5, TimeUnit.MINUTES)
                .doOnNext(n -> YOUR_FUNCTION_NAME()).subscribe();

REPLACE YOUR_FUNCTION_NAME with your function name

When you need to stop this just use the below code:

 if (!disposable.isDisposed())
            disposable.dispose();
Kamal Nayan
  • 1,635
  • 1
  • 5
  • 19