2

We are wanting to implement an offline mode for our react-native application. We will be working with quite large amount of data (aprox. 40-50mb). It is an array of aprox. 16000 objects. As far as I know, there are two ways to save this data.

  1. Using AsyncStorage - android has a limit of 6mb, but I've read somewhere, that it can be increased.

  2. Using json file - Downloading that data as json file using react-native-background-downloader and then using react-native-fs to save it and load it if the user has no connection to internet.

Personally I think that the second option is better, even though it requires permission to file storage.

Am I missing any other factors to consider? Are there any other options for offline access?

Jiří Petera
  • 304
  • 2
  • 10
  • 1
    I think the android async storage limit is up to 10 Mb. I think the best solution when store on device storage, the asyncstorage is better for local db like redux or something like this, and if I can suggest, you should use expo-file-system, because it is maintained and the react-native-fs and react-native-fetch-blob are outdated. – Dániel Boros Apr 20 '21 at 08:56
  • @Jiří Petera - Did you find a solution at the end? I'm facing a similar scenario where I want to store locally a JSON of about 7 Mb and then pass it to Redux to be used across the app during the session. That would offer users offline option and I would save download from Firebase database. – Butri Sep 11 '21 at 21:22
  • I'm having the same issue - would love to hear anyones thoughts on this - not a huge amount online. Playing around with SQLlite and fs solutions currently. – James Trickey Oct 03 '21 at 10:19

1 Answers1

2

In the end opted out for usage of the json file as there is limit on android. On load of the application I take these data and load them into variable in mobX store. Which functions same as any variable. I was afraid that mobile phones will have problem sorting across the 16000 objects in array, but there have been no reports of this thing going wrong so far. (In production for 4-5 months right now)

So basically when you hit "enable offline mode" I ask for the file storage permission and download the file using react-native-fs. Then on the next startup of the application I just read the data off the JSON file.

Jiří Petera
  • 304
  • 2
  • 10
  • I'm using expo-storage and works perfectly, basically saves the file locally, if the file is there it won't fetch it again and save on downloads as well. Transferring data from file to Redux store – Butri Oct 06 '21 at 15:01