hive icon indicating copy to clipboard operation
hive copied to clipboard

On app deletion, Hive database is not removed on certain phone models

Open subzero911 opened this issue 3 years ago • 3 comments

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

subzero911 avatar Nov 15 '22 08:11 subzero911

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.

JDMukiibs avatar Nov 22 '22 07:11 JDMukiibs

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

Zaveri21 avatar Mar 15 '23 06:03 Zaveri21

Any update on this issue?

pranavo72bex avatar Mar 14 '25 06:03 pranavo72bex