skip to Main Content

I store my users’ login information in shared preferences,
But if the user deletes the app and reinstalls, the same information is still stored and user is logged in with the previously stored info,
It seems like the shared preferences doesn’t get cleared if the app gets deleted.

I have this problem with android 14

3

Answers


  1. Try adding this to your AndroidMenifest:

    android:allowBackup = "false"
    

    Setting this attribute false will disable the auto backup of your Shared Preferences.
    Check this to know more about allowBackup attribute.

    Login or Signup to reply.
  2. In your <application> object inside your app manifest, try adding android:allowBackup="false" tag to disable this behaviour.

    If android:allowBackup tag clashes with any other library you are using, you should add tools:replace="android:allowBackup" also.

    I think its android feature.

    Hope this helps.

    Login or Signup to reply.
  3. Android might be restoring the app’s data using Auto Backup when the app is reinstalled. By default, Auto Backup includes files in the app’s internal storage, including SharedPreferences.

    To disable Auto Backup and ensure SharedPreferences data does not persist after uninstall, add the following to your AndroidManifest.xml file:

    <application
    android:allowBackup="false"
    android:fullBackupContent="false"
    … >

    android:allowBackup="false" ensures that no data, including SharedPreferences, will be backed up to Google Drive.
    android:fullBackupContent="false" disables backup for all files

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search