This is where I wanted to record, every second was being recorded. But I want data to be added every 5 minutes
            Asked
            
        
        
            Active
            
        
            Viewed 108 times
        
    -1
            
            
        - 
                    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 Answers
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
 
