How to know when the AsyncStorage in React-Native is Full?

Viewed 1914

I want to know when AsyncStorage is full in react native.

What do Error value we get when the AsyncStorage is full to react native or will something else happen?

We can get a value from AsyncStorage using the below code

try {
    const value = await AsyncStorage.getItem('TASKS');
    if (value !== null) {
      // We have data!!
      console.log(value);
    }
   } catch (error) {
     // Error retrieving data
   }

if someone can suggest me a check in the above code to know when AsyncStorage is full. It would be really helpful.

1 Answers

Do the steps

import {AsyncStorage} from 'react-native';

AsyncStorage.setItem('Islogin', 'Yes');

And check that you have stored or not.

  _storeData = async () => {
    try {
      let value = await AsyncStorage.getItem('Islogin');

      if (value) {
        if (value == 'Yes'){

           console.log("You are auto login");

        }else{
           console.log("abc");
        }
      }else{
           console.log("abc");
      }
    } catch (error) {
              console.log("error" + error);
    }
  }
Related