An Android App Remembers Its Data After Uninstall and Reinstall

An Android app remembers its data after uninstall and reinstall

It's because Android 6 has automatic backup. You need to tune android:allowBackup and android:fullBackupContent in your manifest <application> tag if you don't want your data backed up or if you want to include or exclude some resources. It's not a bug.

More about AutoBackup on Android here.

Is it possible to persisit a file after app uninstall with Android 11?

If the file already exists and not trying to create the file at the time of being uninstalled your options are limited and not really good.

There is no way to keep a file around without user interaction. Your only option is really to use the Storage Access Framework to save the file. What happens here is you have to have the user pick where they want to save the file via file picker intent. Get the uri path in onActivityResult and use that to save the file.

Aside from requiring user intervention this also puts your file that has the licensing information in a publicly accessible location where anyone can get it which might not be something you want

That's really your only option if you want to keep a file around after your app has been uninstalled.

Getting old data after reinstallation of my app in android

You may rarely face issue in older than Marshmallow version but you may face this issue in Marshmallow version because in Marshmallow all the app data are backed up. So first thing you need to set allowBackup as false in manifest as default is true so if you don't mention below code it will take it as true by default.

<application
android:allowBackup="false"
..
>

Then search for a folder in internal as well as external memory with the name as your app package name and delete it and restart your phone.

My application remembers the login password after deleting it and install it new

As far as I know, It's a good way to use SharedPreferences when you need to save Login Password, Now coming to your main question, You might have android:allowBackup="true" in your manifest, Try passing "False" instead

Update

Just for your information, SharedPreferences deletes the info on uninstallation.

Retaining data after uninstalling the app

Yeah it's possible if you save App Data in External Storage of your device because that data is not deleted even if your app is uninstalled.

Upon reinstalling the app, you can read the file data to determine was the app previously installed or it is a fresh install in case that file doesn't exists.

Note:- Data in External Directory would be visible to user so it might be a case that user may delete the data from file manager.

Android remembers shared preferences after complete app uninstall

On (re)install, your app may be restoring files from Google auto-backup (via Google Drive). To disable this feature, you can explicitly set it to false in the manifest:

<manifest ... >
...
<application android:allowBackup="false" ... >
...
</application>
</manifest>

If you'd like more granular control over what is backed up/restored and what is not, you can include or exclude specific files from the backups.

See auto backup documentation:
https://developer.android.com/guide/topics/data/autobackup#EnablingAutoBackup

If you don't want to disable auto backups, but want to reinstall with a "clean slate" (for testing purposes), you can do one of the following:

  • Clear app data after reinstall. This will wipe out files that were restored automatically on install
  • Clear app data prior to uninstall, then force a new backup (so old one gets reset) by using this command: adb shell bmgr backupnow <PACKAGE>

See how to test backups documentation:
https://developer.android.com/guide/topics/data/testingbackup#TestingBackup



Related Topics



Leave a reply



Submit