应用程序数据库不会在应用程序卸载 Flutter 时被删除
App database is not deleted on app uninstall Flutter
在我的应用程序中,我刚刚意识到在 Android 上卸载应用程序时 Sembast 数据库没有被删除,在 iOS 上它确实被删除了。
在这里查看其他答案,我看到为了防止 Android 备份,在 AndroidManifest.xml
中设置了标志 android:allowBackup="false"
。所以我在 android/main/app 中为 Manifest 做了。没有改变。应用程序卸载并重新安装后,数据库仍然存在。
由于我的 phone 使用 Android 7.0 API 24 我想这个标志会影响下一次安装,但我必须手动删除数据库。这次。
我是否正确添加了这个标志?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vinny.fixit_cloud_biking">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:name="io.flutter.app.FlutterApplication"
android:label="fixit"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:allowBackup="false">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
我试图在 phone 目录 Android/data/com.vinny.fixit_cloud_biking/files 中寻找 db 文件夹,但只有一个 Pictures
文件夹。我在哪里可以删除旧数据库?这是单例中声明的路径 final dbPath = join(appDocumentDir.path, 'device.db');
尝试在 <application>
级别而不是 <activity>
级别添加 android:allowBackup="false"
<application
android:name="io.flutter.app.FlutterApplication"
android:allowBackup="false"
试试这个
将其添加到清单标签中
xmlns:tools="http://schemas.android.com/tools"<br>
tools:replace="allowBackup"<br>
android:allowBackup="false"<br>
<?xml version='1.0' encoding='utf-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:replace="allowBackup"
android:allowBackup="false"/>
还可以加
android:allowBackup="false"
(在应用程序标签上)
在我的应用程序中,我刚刚意识到在 Android 上卸载应用程序时 Sembast 数据库没有被删除,在 iOS 上它确实被删除了。
在这里查看其他答案,我看到为了防止 Android 备份,在 AndroidManifest.xml
中设置了标志 android:allowBackup="false"
。所以我在 android/main/app 中为 Manifest 做了。没有改变。应用程序卸载并重新安装后,数据库仍然存在。
由于我的 phone 使用 Android 7.0 API 24 我想这个标志会影响下一次安装,但我必须手动删除数据库。这次。
我是否正确添加了这个标志?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vinny.fixit_cloud_biking">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:name="io.flutter.app.FlutterApplication"
android:label="fixit"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:allowBackup="false">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
我试图在 phone 目录 Android/data/com.vinny.fixit_cloud_biking/files 中寻找 db 文件夹,但只有一个 Pictures
文件夹。我在哪里可以删除旧数据库?这是单例中声明的路径 final dbPath = join(appDocumentDir.path, 'device.db');
尝试在 <application>
级别而不是 <activity>
级别添加 android:allowBackup="false"
<application
android:name="io.flutter.app.FlutterApplication"
android:allowBackup="false"
试试这个
将其添加到清单标签中
xmlns:tools="http://schemas.android.com/tools"<br>
tools:replace="allowBackup"<br>
android:allowBackup="false"<br>
<?xml version='1.0' encoding='utf-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:replace="allowBackup"
android:allowBackup="false"/>
还可以加
android:allowBackup="false"
(在应用程序标签上)