On app deletion, Hive database is not removed on certain phone models
It's reported that on some devices, such as Xiaomi Redmi Note 9 Pro, Samsung Galaxy S21 FE (Android 12, One UI 4.1), after removing and reinstalling the app, Hive database still persists.
Steps to Reproduce
- uninstall the app
- reinstall the app
https://user-images.githubusercontent.com/12999702/201874997-d09ba8cd-1a0d-4b5d-880c-13ad158a9c05.mp4
Expected result: it starts from the intro screen Actual result: it starts from the PIN-code screen (having a previous user's PIN saved somehow)
Version
- Platform: Android
- Flutter version: 3.3.6
- Hive version: ^2.1.0
I faced a similar problem a while back as well. I think it might be due to the backup apps feature on Android 12 it works differently from previous versions. I had to go into the app settings and clear app data to prevent it from using the last data that might have been backed up and restored upon re-installation. I don't know if you've read how to control the backup section on this page, but you can find out more here.
Android 12 and higher version - automatic backup: true
data will not clear even after app uninstall, later android 11 shred preference working differently check here
to resolve this issue you need add data extraction rule in native android platforms. create a file app/src/main/res/xml/data_extraction_rules.xml: under android native app folder.
<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
<cloud-backup>
<exclude domain="root" />
<exclude domain="file" />
<exclude domain="database" />
<exclude domain="sharedpref" />
<exclude domain="external" />
</cloud-backup>
<device-transfer>
<exclude domain="root" />
<exclude domain="file" />
<exclude domain="database" />
<exclude domain="sharedpref" />
<exclude domain="external" />
</device-transfer>
</data-extraction-rules>
Now in your AndroidManifest.xml file with add attribute android:dataExtractionRules="@xml/data_extraction_rules" under application tag.
<application
....
android:dataExtractionRules="@xml/data_extraction_rules"
...
</application>
for more details checkout this link
Any update on this issue?