diff --git a/native/android/app/src/main/java/app/comm/android/MainApplication.java b/native/android/app/src/main/java/app/comm/android/MainApplication.java --- a/native/android/app/src/main/java/app/comm/android/MainApplication.java +++ b/native/android/app/src/main/java/app/comm/android/MainApplication.java @@ -6,10 +6,6 @@ import androidx.annotation.NonNull; import androidx.multidex.MultiDexApplication; import app.comm.android.commservices.CommServicesPackage; -import app.comm.android.fbjni.CommMMKV; -import app.comm.android.fbjni.CommSecureStore; -import app.comm.android.fbjni.DatabaseInitializer; -import app.comm.android.fbjni.GlobalDBSingleton; import app.comm.android.newarchitecture.MainApplicationReactNativeHost; import app.comm.android.notifications.CommAndroidNotificationsPackage; import com.facebook.react.PackageList; @@ -23,7 +19,6 @@ import com.wix.reactnativekeyboardinput.KeyboardInputPackage; import expo.modules.ApplicationLifecycleDispatcher; import expo.modules.ReactNativeHostWrapper; -import java.io.File; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.security.Security; @@ -91,8 +86,6 @@ Security.insertProviderAt(new org.conscrypt.OpenSSLProvider(), 1); SoLoader.init(this, /* native exopackage */ false); - this.initializeDatabase(); - CommMMKV.initialize(); ApplicationLifecycleDispatcher.onApplicationCreate(this); try { Field field = CursorWindow.class.getDeclaredField("sCursorWindowSize"); @@ -114,15 +107,4 @@ public static Context getMainApplicationContext() { return MainApplication.context; } - - private void initializeDatabase() { - File sqliteFile = - this.getApplicationContext().getDatabasePath("comm.sqlite"); - CommSecureStore.getInstance().initialize( - ExpoUtils.createExpoSecureStoreSupplier(this.getApplicationContext())); - - GlobalDBSingleton.scheduleOrRun(() -> { - DatabaseInitializer.initializeDatabaseManager(sqliteFile.getPath()); - }); - } } diff --git a/native/android/app/src/main/java/app/comm/android/fbjni/CommHybrid.java b/native/android/app/src/main/java/app/comm/android/fbjni/CommHybrid.java --- a/native/android/app/src/main/java/app/comm/android/fbjni/CommHybrid.java +++ b/native/android/app/src/main/java/app/comm/android/fbjni/CommHybrid.java @@ -1,8 +1,12 @@ package app.comm.android.fbjni; import android.content.Context; +import app.comm.android.fbjni.CommMMKV; +import app.comm.android.fbjni.DatabaseInitializer; +import app.comm.android.fbjni.GlobalDBSingleton; import com.facebook.react.bridge.ReactContext; import com.facebook.react.turbomodule.core.CallInvokerHolderImpl; +import java.io.File; import java.util.HashMap; public class CommHybrid { @@ -17,12 +21,18 @@ long contextPointer = context.getJavaScriptContextHolder().get(); // additional parameters - String sqliteFilePath = context.getDatabasePath("comm.sqlite").toString(); + File sqliteFile = context.getDatabasePath("comm.sqlite"); + String sqliteFilePath = sqliteFile.toString(); HashMap additionalParameters = new HashMap(); additionalParameters.put("sqliteFilePath", sqliteFilePath); new CommHybrid().initHybrid(contextPointer, holder, additionalParameters); + + GlobalDBSingleton.scheduleOrRun(() -> { + DatabaseInitializer.initializeDatabaseManager(sqliteFile.getPath()); + }); + CommMMKV.initialize(); } public native void initHybrid(