SQLite vs AsyncStorage


#1

Hi,

i am working on creating and app that will download, upload, store many images. i am trying to see how best to manage the data for performance.

i am using Redux to store the state of my app and i use redux-persist to store the state in AsyncStorage.

but i also understand that create-react-native-app also provides a module called SQLite in the expo package. (https://docs.expo.io/versions/latest/sdk/sqlite.html).

i am trying to find out where it would be a good idea to store my data.

should i store all my images (base64 encoded) into redux? this could amount to up to 100mb of data. or should i store the images into SQLite where i assume the data is stored flat like in an sqlite “.db” file.


#2

Hi @xoron, while you could store your images with base64 encoding in redux, the Expo Filesystem sounds more appropriate for your usecase: https://docs.expo.io/versions/latest/sdk/filesystem.html


#3

hi. thanks for the reply. the expo FileSystem is great, but in my data there is going to be some metadata with each image (which i need to be able to query by).

using expo FileSystem, would mean i would have to query the contents of a directory and read the files individually. this is a perfectly valid solution if you think the performance of reading the contents of a directory one file at a time (asynchronously) is going to faster than AsyncStorage and expo SQLite.

i guess it depends on what the underlying method expo FileSystem uses to store data “locally on the device”.


#4

hey @xoron, so we use the file api’s that the platform exposes for Filesystem (ie) java.io.File for Android. Our Filesystem code is open source, so you can inspect the code to see if it matches your usecase:

android: https://github.com/expo/expo/blob/master/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/FileSystemModule.java

ios: https://github.com/expo/expo/blob/master/ios/Exponent/Versioned/Core/Api/FileSystem/EXFileSystem.m


#5

afaik this should allow you to avoid the overhead of encoding/decoding images from base64 format


closed #6

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.