How large is AsyncStorage in React Native?

前端 未结 4 1229
闹比i
闹比i 2020-12-29 05:04

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

相关标签:
4条回答
  • 2020-12-29 05:25

    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.

    0 讨论(0)
  • 2020-12-29 05:38

    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://github.com/react-native-community/async-storage/blob/LEGACY/docs/advanced/IncreaseDbSize.md

    0 讨论(0)
  • 2020-12-29 05:39

    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);
      }
    
    0 讨论(0)
  • 2020-12-29 05:41

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

    But you can increase that limit calling the method setMaximumSize.

    0 讨论(0)
提交回复
热议问题