Actually return instance in getInstance

This probably fixes all those "db deleted" issues and mysterious NPEs
Previously, the synchronized keyword on open() and close() was useless
because it was synchronizing on different objects in each thread.
This commit is contained in:
ByteHamster 2018-04-06 11:41:08 +02:00
parent 396d9c41a6
commit cfaccef2b3
1 changed files with 5 additions and 1 deletions

View File

@ -312,6 +312,7 @@ public class PodDBAdapter {
private static volatile SQLiteDatabase db;
private static int counter = 0;
private static PodDBAdapter instance;
public static void init(Context context) {
PodDBAdapter.context = context.getApplicationContext();
@ -322,8 +323,11 @@ public class PodDBAdapter {
}
public static PodDBAdapter getInstance() {
if (instance == null) {
instance = new PodDBAdapter();
}
dbHelper = PodDBHelperholder.dbHelper;
return new PodDBAdapter();
return instance;
}
private PodDBAdapter() {