11

I made a small mobile app using flutter. When using it, it saves data locally into the Sqlite database. When I uninstall it , the database seems to get deleted as well, so next time I install the app again, the data is gone. Any ideas how to leave the database file in the phone even the app is deleted? Thank you.

Jitesh Mohite
  • 31,138
  • 12
  • 157
  • 147
Benson
  • 189
  • 2
  • 9
  • 1
    did you find an answer for this question? I am currently having the same question like yours – wahyu May 14 '20 at 06:50

3 Answers3

6

This issue exists if your device is Android 6 (API level 23) and above, where android supports automatic backup, which means data will be stored in the device even if you uninstall the application.

For Android:

To get rid of this, go to the AndroidManifest file and add

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

For iOS: refer https://stackoverflow.com/a/57937650/5106574

Jitesh Mohite
  • 31,138
  • 12
  • 157
  • 147
1

I do not know how to do this in iOS but for Android there is a way.

Apps that target Android 6.0 (API level 23) or higher automatically participate in Auto Backup.

In your app manifest file, set the boolean value android:allowBackup to enable or disable backup.

The default value is true.

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

The restore operation occurs after the APK is installed, but before the app is available to be launched by the user.

You can check out more information over here:

ibhavikmakwana
  • 8,948
  • 4
  • 20
  • 39
0

I think the best way to take backup, save db as a txt file, and set your file in somewhere disk device . Reading_Writing_file

OR create new db as a backup db Example