sqlitereact-nativeasyncstorage

React Native AsyncStorage | Row too big to fit into CursorWindow


I'm using AsyncStorage in ReactNative to store some data (large size >2MB) on device, and then read it with the following code

try {
   const value = await AsyncStorage.getItem('date_stored_copy');
} catch (e) {
   console.log(e);
}

I'm getting the following error:

Row too big to fit into CursorWindow requiredPos=0, totalRows=1...

Is there any way to increase CursorWindow size, or another alternative to AsyncStorage ?


Solution

  • I found another alternative mentioned here

    Just install react-native-fs-store

    npm i react-native-fs react-native-fs-store
    
    react-native link react-native-fs
    

    And use it like this:

    import Store from "react-native-fs-store";
    const AsyncStorage = new Store('store1');
    

    it has has exactly same API as that of AsyncStorage, so no code changes are required

    ** Please notice that react-native-fs-store is slower than AsyncStorage, as each operation is synced to file. So you may notice lag (unresponsive screen) while reading/writing data