0

I have created react native sample app with realm , and i have pre populated realm with default data using realm studio, when i create apk file and install mobile device it shows no data, Is React-native create new realm file when each user install apk on their devices?

Roshan
  • 3,236
  • 10
  • 41
  • 63
  • 1
    Yes, realm files are stored locally on each mobile, on the app local storage, they are not accessible from a server. You may want to check about realm object server if you want to store them somewhere common for every apk installed. – angelos_lex Jan 30 '19 at 19:46
  • @angelos_lex I try to do something like this , say i have some data that show to user initially , so i have stored that data in realm without using seeders , and pushed that realm file to /data/data/app_name/files/realmfile.realm when i run this app on emulator , it shows data , but when i build apk and installed on real device data is not shows, sorry if this dumb question , im new to react-native. – Roshan Jan 30 '19 at 19:48
  • Yes this is normal, since when new app is installed, it doesn't have any realmfile. What you are trying to achieve, probably requires either the use of realm object server, or maybe the bundling of the realmfile.realm inside the apk – angelos_lex Jan 31 '19 at 10:17
  • @angelos_lex could you please guide me how to bundle realm file with apk, – Roshan Feb 01 '19 at 04:08
  • how many data do you have when you pre-fill your realm database, if it's not much you could do it in your `App.java` because embedding a realm file can lead to a much heavier apk file – Maelig Feb 01 '19 at 14:01
  • @Roshan i haven't done it ever, but i can see doc for [ios side](https://realm.io/docs/swift/latest/#bundling-a-realm) and for [android side](https://stackoverflow.com/questions/35933804/how-can-i-bundle-a-realm-database-file-with-my-app-to-deploy-with-installation), or maybe [here](https://github.com/realm/realm-js/issues/816) as they say for react native – angelos_lex Feb 02 '19 at 09:57

0 Answers0