Run database actions low priority

Why isn't this the default mr Google?
This commit is contained in:
M66B 2019-01-04 14:48:55 +00:00
parent 7119f537ce
commit e8f18afd28
1 changed files with 4 additions and 0 deletions

View File

@ -12,6 +12,8 @@ import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.mail.Address;
import javax.mail.internet.InternetAddress;
@ -79,6 +81,7 @@ public abstract class DB extends RoomDatabase {
public abstract DaoLog log();
private static DB sInstance;
private static ExecutorService executor = Executors.newCachedThreadPool(Helper.backgroundThreadFactory);
private static final String DB_NAME = "fairemail";
@ -87,6 +90,7 @@ public abstract class DB extends RoomDatabase {
sInstance = migrate(context, Room
.databaseBuilder(context.getApplicationContext(), DB.class, DB_NAME)
.openHelperFactory(new RequerySQLiteOpenHelperFactory())
.setQueryExecutor(executor)
.setJournalMode(JournalMode.WRITE_AHEAD_LOGGING));
Log.i("sqlite version=" + exec(sInstance, "SELECT sqlite_version() AS sqlite_version"));