database adapter fix

Signed-off-by: nuclearfog <hatespirit666@gmail.com>
This commit is contained in:
nuclearfog 2021-10-25 14:05:23 +02:00
parent 1339ee0d7d
commit 01f0037229
No known key found for this signature in database
GPG Key ID: AA0271FBE406DB98
2 changed files with 6 additions and 10 deletions

View File

@ -288,7 +288,7 @@ public class AppSettings extends AppCompatActivity implements OnClickListener, O
} }
// confirm delete database // confirm delete database
else if (type == DialogType.DEL_DATABASE) { else if (type == DialogType.DEL_DATABASE) {
DatabaseAdapter.deleteDatabase(getApplicationContext()); DatabaseAdapter.deleteDatabase(this);
setResult(RETURN_DB_CLEARED); setResult(RETURN_DB_CLEARED);
} }
// confirm leaving without saving proxy changes // confirm leaving without saving proxy changes

View File

@ -198,10 +198,7 @@ public class DatabaseAdapter {
*/ */
private SQLiteDatabase db; private SQLiteDatabase db;
private boolean isInitialized = false;
/** /**
*
*/ */
private DatabaseAdapter() { private DatabaseAdapter() {
} }
@ -224,7 +221,7 @@ public class DatabaseAdapter {
* @return database instance * @return database instance
*/ */
public static DatabaseAdapter getInstance(@NonNull Context context) { public static DatabaseAdapter getInstance(@NonNull Context context) {
if (!INSTANCE.isInitialized) if (INSTANCE.db == null)
INSTANCE.init(context.getApplicationContext()); INSTANCE.init(context.getApplicationContext());
return INSTANCE; return INSTANCE;
} }
@ -249,7 +246,6 @@ public class DatabaseAdapter {
db = c.openOrCreateDatabase(databasePath.toString(), MODE_PRIVATE, null); db = c.openOrCreateDatabase(databasePath.toString(), MODE_PRIVATE, null);
initTables(); initTables();
updateTable(); updateTable();
isInitialized = true;
} }
/** /**
@ -639,21 +635,21 @@ public class DatabaseAdapter {
} }
/** /**
* * table for user filter list
*/ */
public interface UserExcludeTable { public interface UserExcludeTable {
/** /**
* * table name
*/ */
String NAME = "userExclude"; String NAME = "userExclude";
/** /**
* * owner ID of the list
*/ */
String OWNER = "listOwner"; String OWNER = "listOwner";
/** /**
* * user ID to filter
*/ */
String ID = "userID"; String ID = "userID";
} }