Iam running this procedure to download some data and insert them into the database. The total procedure takes around 5 minutes. I noticed that while downloading, when the phone locks the screen and open it after 5 minutes, it will still downloading. It seems when locked download procedure slows down. Is there any explanation?
The execution time also slows down when pressing home button and becomes a background process, not only when sreen locks.
Thank you
public abstract class AppDatabase extends RoomDatabase {
private static AppDatabase sInstance;
@VisibleForTesting
public static final String DATABASE_NAME = "Database_db";
public abstract CustomerDao repoCustomer();
public static AppDatabase getInstance(Context context) {
if (sInstance == null) {
synchronized (AppDatabase.class) {
if (sInstance == null) {
sInstance = Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, DATABASE_NAME).build();
}
}
}
return sInstance;
}
public void downloadCustomers(final String table){
executors.diskIO().execute(new Runnable() {
@Override
public void run() {
//download data and insert into database.
});
}
}