Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing big data on a mobile device, iOS and Android, with react native and expo SQLite

I am working on a mobile app with react native and expo. The critical point of the app is that it needs to store big data on a device because it will work in offline and online modes both. I'm thinking to try expo SQLite for this and I have few questions regarding this:

  1. Is it appropriate for storing large data on the local device, both Android and iOS?
  2. When deleting data, does the database file size decrease, or stay as is?
  3. Are there any limitations to TEXT type?
  4. Can you suggest any good documentation, because on expo.io is too short (i think )?

Thanks in advance!

like image 604
E. Stoyanov Avatar asked Oct 22 '25 02:10

E. Stoyanov


2 Answers

1) Storing large data on a react native app

Redux-persist and SQLite are not ideal ways to store large data on mobile devices. You can store your data on the application storage managed by the relevant OS. You can use Documents or /Library/Caches or tmp directories on iOS and external storage or external sd card on Android. You will need read-write permissions on Android, you can use react-native-permissions to handle it. react-native-fs is a good library to save, read or delete files.

2) Deleting data

If you store a binary or text in your database when you delete that record, it will reduce your database size. But if you store your file in the documents folder and add a reference to your database, deleting this reference won't remove the actual file from the device. You need to do this yourself.

3) SQLite limitations

I assume you are storing binaries. Regardless of the data type, there is a limit for SQLite Text type which is 2 GB. You can see more info here

4) Suggestions

I would prefer storing data in local storage as explained above and keep the references in Async Storage managed by redux-persist or a local SQLite database.

like image 170
aytek Avatar answered Oct 24 '25 19:10

aytek


I just use expo-file-system as all my data is stored in a single tree so it's easy to async write it to file after every update and load it when the app opens.

like image 34
Brian F Avatar answered Oct 24 '25 17:10

Brian F



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!