Make ReactDatabaseSupplier use application context
Summary: public We pass in a `ReactContext` but we really only need a context. Make sure we're using the application one. Reviewed By: astreet Differential Revision: D2690692 fb-gh-sync-id: 857d6571c9c01d35e12f09be4c8733cca007306f
This commit is contained in:
parent
3a00545bc7
commit
5387df8dc5
|
@ -42,9 +42,10 @@ public class ReactDatabaseSupplier extends SQLiteOpenHelper {
|
|||
VALUE_COLUMN + " TEXT NOT NULL" +
|
||||
")";
|
||||
|
||||
private static @Nullable ReactDatabaseSupplier sReactDatabaseSupplierInstance;
|
||||
|
||||
private Context mContext;
|
||||
private @Nullable SQLiteDatabase mDb;
|
||||
private static @Nullable ReactDatabaseSupplier mReactDatabaseSupplierInstance;
|
||||
|
||||
private ReactDatabaseSupplier(Context context) {
|
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||
|
@ -52,10 +53,10 @@ public class ReactDatabaseSupplier extends SQLiteOpenHelper {
|
|||
}
|
||||
|
||||
public static ReactDatabaseSupplier getInstance(Context context) {
|
||||
if (mReactDatabaseSupplierInstance == null) {
|
||||
mReactDatabaseSupplierInstance = new ReactDatabaseSupplier(context);
|
||||
if (sReactDatabaseSupplierInstance == null) {
|
||||
sReactDatabaseSupplierInstance = new ReactDatabaseSupplier(context.getApplicationContext());
|
||||
}
|
||||
return mReactDatabaseSupplierInstance;
|
||||
return sReactDatabaseSupplierInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -150,6 +151,6 @@ public class ReactDatabaseSupplier extends SQLiteOpenHelper {
|
|||
|
||||
// For testing purposes only!
|
||||
public static void deleteInstance() {
|
||||
mReactDatabaseSupplierInstance = null;
|
||||
sReactDatabaseSupplierInstance = null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue