Ryan McDermott
Ryan McDermott

Reputation: 6305

How large is AsyncStorage in React Native?

The documentation says it should be used instead of LocalStorage, but it doesn't list anything regarding how large it is. If I recall, LocalStorage in web browsers is only about 10mb.

https://facebook.github.io/react-native/docs/asyncstorage.html

Upvotes: 29

Views: 29621

Answers (4)

Justin Lok
Justin Lok

Reputation: 1270

The new way of increasing AsyncStorage size on react-native is to add AsyncStorage_db_size_in_MB= property to your android/gradle.properties as shown here: https://react-native-async-storage.github.io/async-storage/docs/advanced/db_size/

Upvotes: 15

Mujtaba Fadhil
Mujtaba Fadhil

Reputation: 6116

This is an old answer, the new method is mentioned in justin answer above..


As mentioned here, to increase the 6mb limit on Android.. try this:

in MainApplication.java add these lines in onCreate function

  public void onCreate() {
    // ...
    long size = 50L * 1024L * 1024L; // 50 MB
    com.facebook.react.modules.storage.ReactDatabaseSupplier.getInstance(getApplicationContext()).setMaximumSize(size);
  }

Upvotes: 3

Sandro Machado
Sandro Machado

Reputation: 10215

On Android the limit is 6mb by default. Check this.

But you can increase that limit calling the method setMaximumSize.

Upvotes: 2

ide
ide

Reputation: 20808

It writes to disk and is very large if there is free space. On iOS there are no artificial caps other than what the underlying operating system imposes: https://stackoverflow.com/a/1897383/454967.

Upvotes: 22

Related Questions