Delete FTS DB on corruption

pull/180/head
M66B 5 years ago
parent 897c490784
commit 9c4415ac41

@ -27,6 +27,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.database.sqlite.SQLiteDatabaseCorruptException;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
@ -192,9 +193,14 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
SQLiteDatabase sdb = FtsDbHelper.getInstance(context);
FtsDbHelper.delete(sdb);
FtsDbHelper.optimize(sdb);
try {
SQLiteDatabase sdb = FtsDbHelper.getInstance(context);
FtsDbHelper.delete(sdb);
FtsDbHelper.optimize(sdb);
} catch (SQLiteDatabaseCorruptException ex) {
Log.e(ex);
FtsDbHelper.delete(context);
}
DB db = DB.getInstance(context);
db.message().resetFts();

@ -174,4 +174,8 @@ public class FtsDbHelper extends SQLiteOpenHelper {
Log.i("FTS optimize");
db.execSQL("INSERT INTO message (message) VALUES ('optimize')");
}
static void delete(Context context) {
context.getDatabasePath(DATABASE_NAME).delete();
}
}

Loading…
Cancel
Save