From 5387df8dc569c3dfbb5ba4d66b88f70c5ec22d50 Mon Sep 17 00:00:00 2001 From: Alexander Blom Date: Tue, 24 Nov 2015 09:46:58 -0800 Subject: [PATCH] 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 --- .../react/modules/storage/ReactDatabaseSupplier.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/storage/ReactDatabaseSupplier.java b/ReactAndroid/src/main/java/com/facebook/react/modules/storage/ReactDatabaseSupplier.java index ef27b332f..620d23146 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/storage/ReactDatabaseSupplier.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/storage/ReactDatabaseSupplier.java @@ -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; } }