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

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

Loading…
Cancel
Save