Run VACUUM on boot/update

This commit is contained in:
M66B 2019-07-22 16:28:48 +02:00
parent 0fe0b4857e
commit c97ea7556f
1 changed files with 12 additions and 3 deletions

View File

@ -101,10 +101,19 @@ public abstract class DB extends RoomDatabase {
private static final String DB_NAME = "fairemail";
public static synchronized DB getInstance(Context ctx) {
public static synchronized DB getInstance(Context context) {
if (sInstance == null) {
Context context = ctx.getApplicationContext();
sInstance = migrate(context, getBuilder(context));
Context acontext = context.getApplicationContext();
sInstance = migrate(acontext, getBuilder(acontext));
// https://www.sqlite.org/lang_vacuum.html
try {
Log.i("Running VACUUM");
sInstance.getOpenHelper().getWritableDatabase().execSQL("VACUUM;");
} catch (Throwable ex) {
Log.e(ex);
}
sInstance.getInvalidationTracker().addObserver(new InvalidationTracker.Observer(
EntityAccount.TABLE_NAME,