Sunday, September 30, 2018

Share Database between React Native Apps

Leave a Comment

I am building two react native apps where i need to keep few things in common like username(login) and few other information.I tried to store using AsyncStorage (React Native Storage) and everything was working but now i need to use one common data base for both the apps as the user login success in first app then the other app should also be logged in.As Asyncstorage cannot be used in this case any other option in react native.

USE CASE FLOW

3 Answers

Answers 1

The new privacy laws do not let share the same database for 2 applications. The only thing you can do is put the database online and access to it by both apps. At least it happen in Europe. Anyway you can't use the same AsyncStorage to 2 different apps. See more here: https://stackoverflow.com/a/48806319/8898886

Answers 2

In Android, the system design do not permit that. Every app has its own sandbox. Shortly, an app can not access the database of another app.

But it could be swindled, at your risk.

You could use a sqlite database, put the database file in a shared directory, and access that file from each app. Please note that each means really each. Every app on the device could access that file, so it is not a safe place for sensible data.

The best solution, as proposed, is to use a external db, accessible from the network, to store your data. If you belive that the effort is not worth it, you could use Firebase, for example.

Answers 3

You can not use that locally. But with Firebase you can make 2 app have same Firebase Realtime database so you can share data between 2 app (event realtime). I prefer use this react-native-firebase library for React Native https://github.com/invertase/react-native-firebase

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment