Search code examples
react-nativerealm

Is there a way to check if the Realm database exists? (React Native)


I'm developing an application that has initial database. I'd like to copy it using Realm.copyBundledRealmFiles() only if the database is not exist. Is there a way to check it?

I know about react-native-fs library (I can check whether database file exists), but I don't want to add it to the project for a small using.

Maybe there's another way?

Thanks for your help in advance.


Solution

  • I found an answer here: https://github.com/realm/realm-js/issues/532#issuecomment-251477484

    It's said that utility method Realm.copyBundledRealmFiles() copies all realm files from the root of the resources directory to the Documents directory if they don't yet exist.

    Maybe this information will be helpful.