mCodex/react-native-sensitive-info

getItem on android after delete app data is lost

freedomzzzii opened this issue · 2 comments

I use setItem to storage value on device and delete app after delete app i reinstall this app and use getItem to get data from storage but data is lost on Android but IOS is work. anyone can help, i don't kwon what's wrong on my code. Thanks.

package version
"react-native-sensitive-info": "^6.0.0-alpha.9",
"react": "16.13.1",
"react-native": "0.63.4",

my code

import SInfo from 'react-native-sensitive-info';

  const set = async () => {
      try {
        const val = await SInfo.setItem('key1', 'value1', {
          sharedPreferencesName: 'mySharedPrefs',
          keychainService: 'myKeychain',
        });
  
        console.log('set>>>>', val)
      } catch (error) {
        throw error
      }
    }
  
    const get = async () => {
      try {
        const val = await SInfo.getItem('key1', {
          sharedPreferencesName: 'mySharedPrefs',
          keychainService: 'myKeychain'
        });
        console.log('get>>>>', val)
      } catch (error) {
        throw error
      }
    }

`

@freedomzzzii hello, maybe is because Android stores data on app's cache and when you delete it Android clears every user data/cache from that app. On the other hand, iOS stores it into keychain which is saved separated from the app data.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.