andpor / react-native-sqlite-storage

Full featured SQLite3 Native Plugin for React Native (Android and iOS)
MIT License
2.76k stars 520 forks source link

[Android] You attempted to set the key `dblocation` Error upon opening database #463

Closed panda0603 closed 3 years ago

panda0603 commented 3 years ago
Upon opening the application and the database, I get the following error in Android ``` [Error: You attempted to set the key `dblocation` with the value `"nosync"` on an object that is meant to be immutable and has been frozen.] ``` Opening the app first time when the app is totally killed, works fine. It opens db without a problem. However, when I try to open the app again after pressing hardware back button to quit the app and open the app again (without killing the app from the process manager), above error occurs and cannot proceed further. At the moment I am storing the db instance created by openDatabase method to mobx(state management) observable variable to use it everywhere within the app. Could this be problem? If storing db instance in global state is a problem, what is the most appropriate way to access the db instance across the entire app? ## Expected Behavior SQLite db should open fine. ## Steps to Reproduce (for bugs) This is my open database config for android: ``` const db = SQLite.openDatabase({name: DB_NAME}, openCB, errorCB); ``` ## Your Environment
panda0603 commented 3 years ago

solved issue by changing the architecture. assigning the db instance to global mobx state was the problem.

apapalillo commented 3 years ago

Hi, I'm having the same issue. What did you do to fix this?