Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it okay to store a lot of data with Async Storage? [React Native]

I’m working on a react native app where I have my firebase database storing an inventory of about 10000 items. So I need to store that data locally and I was thinking of saving each item into his own key with async storage. Is that okay or is there a more efficient way?

like image 403
Facundo Silva Avatar asked Apr 05 '19 02:04

Facundo Silva


People also ask

Why should I use asyncstorage?

Because asyncStorage is unencrypted, the stored data is not converted into code or encrypted to prevent unauthorized access, meaning anyone with your device can easily get to the data. However, since it is unencrypted, getting or retrieving data from the asyncStorage is easier and does not involve any further decryption.

What database does asyncstorage use on Android?

On Android, AsyncStorage will use either RocksDB or SQLite based on what is available. The AsyncStorage JavaScript code is a facade that provides a clear JavaScript API, real Error objects, and non-multi functions.

What is the maximum size of asyncstorage programmatically?

On iOS devices, the AsyncStorage is not limited programmatically. On Android devices, the current AsyncStorage size is set to 6MB by default. Reaching this limit is going to result in errors like database or disk is full. There are valid reasons why this limit exists but if there is a need to increase the size, you can do that.

How to read and write data from input using asyncstorage API?

Let us start creating the demo application which is going to save a value from the user's input in the storage and fetch the value from the storage. This reading and writing of data are going to be done with the help of AsyncStorage API functions. Open the App.js file and start by importing the following components.


2 Answers

AsyncStorage has slow runtime and has no indexing capabilities. Because AsyncStorage only accepts string as its value, all data must first be serialized into string before being inserted, and deserialized once retrieved. This is why you should not use AsyncStorage when dealing with a large amount of data

you can read this article for more information on how AsyncStorage works while dealing with large data: https://codeburst.io/tackling-react-native-storage-part-1-d27b2bfa480f

like image 85
Ankush Rishi Avatar answered Oct 14 '22 18:10

Ankush Rishi


You can use AsyncStorage, it will always take a time when you try to retrieve the data from it.

There are other possible way like:

1) React Native SQLite 2

2) React Native Storage

3) Realm

4) React Native Local MongoDB

like image 38
Nirmalsinh Rathod Avatar answered Oct 14 '22 18:10

Nirmalsinh Rathod