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:
parent
396d9c41a6
commit
cfaccef2b3
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue