8
votes

I am new to react native. I want to build an offline react native app for storing user data (Basic user details, user personal documents, images, etc). I already gone through some documents about react-native-sqlite-storage and I would like to integrate it. But not sure,

  1. If I can recover all the user data when user delete application data
  2. What is advantage of using react-native-sqlite-storage than redux-persist for offline app development?
1

1 Answers

0
votes

redux-persist stores persist your state. If your app primarily has API driven data and you want to save states (user data, bookmark, simple lists etc.), redux-persist would work fine as it uses async storage under the hood. However if you want to bundle data so that majority of app works even without internet and there are many data items you'd like to query, ideally sqlite seems better option to me.

redux-persist is built on async storage which uses efficient files based mechanism under the hood. An app's Application Data primarily consist of files created by app. I think, if you create a sqlite DB on initialization or use async storage, it will be lost when users opts for delete application data. However, if you have bundled sqlite database or similar option along with app, it will continue to stay as it's part of the app. In that case, you won't need to recover as data will always be there.

===My answer above seems wrong.. Keeping it for reference for others===

I later came across in a documentation that reactnative-sqlite-storage copies the file to an internal location and then works which means it will be lost too unless you use readonly:true attribute in open database call which makes it useless