Database won't remove when uninstall the Android Application

后端 未结 5 750
执念已碎
执念已碎 2021-01-30 12:49

I have two major questions.

  1. Database won\'t delete when uninstall app.
  2. Downloaded files won\'t delete while unstable the app.

There is a d

相关标签:
5条回答
  • 2021-01-30 13:15

    GUI WAY

    If this is a personal account and you need to delete the backup for testing, you can go to drive.google.com for your account and navigate to the backups section.

    Select a backup and you are given the option to delete the backups for a specific device:

    ADB SHELL WAY

    You can also do this from the command line with the following:

    adb shell bmgr wipe com.google.android.gms/.backup.BackupTransportService com.example.app
    

    You can find more details related to this command here:

    http://www.androiddocs.com/tools/help/bmgr.html#other

    ADB SHELL BACKUP MANAGER USAGE

    The usage for the command can be found here:

    https://github.com/aosp-mirror/platform_frameworks_base/blob/6f357d3284a833cc50a990e14b39f389b8972254/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java#L443

        System.err.println("usage: bmgr [backup|restore|list|transport|run]");
        System.err.println("       bmgr backup PACKAGE");
        System.err.println("       bmgr enable BOOL");
        System.err.println("       bmgr enabled");
        System.err.println("       bmgr list transports");
        System.err.println("       bmgr list sets");
        System.err.println("       bmgr transport WHICH");
        System.err.println("       bmgr restore TOKEN");
        System.err.println("       bmgr restore TOKEN PACKAGE...");
        System.err.println("       bmgr restore PACKAGE");
        System.err.println("       bmgr run");
        System.err.println("       bmgr wipe TRANSPORT PACKAGE");
        System.err.println("");
        System.err.println("The 'backup' command schedules a backup pass for the named package.");
        System.err.println("Note that the backup pass will effectively be a no-op if the package");
        System.err.println("does not actually have changed data to store.");
        System.err.println("");
        System.err.println("The 'enable' command enables or disables the entire backup mechanism.");
        System.err.println("If the argument is 'true' it will be enabled, otherwise it will be");
        System.err.println("disabled.  When disabled, neither backup or restore operations will");
        System.err.println("be performed.");
        System.err.println("");
        System.err.println("The 'enabled' command reports the current enabled/disabled state of");
        System.err.println("the backup mechanism.");
        System.err.println("");
        System.err.println("The 'list transports' command reports the names of the backup transports");
        System.err.println("currently available on the device.  These names can be passed as arguments");
        System.err.println("to the 'transport' and 'wipe' commands.  The currently selected transport");
        System.err.println("is indicated with a '*' character.");
        System.err.println("");
        System.err.println("The 'list sets' command reports the token and name of each restore set");
        System.err.println("available to the device via the current transport.");
        System.err.println("");
        System.err.println("The 'transport' command designates the named transport as the currently");
        System.err.println("active one.  This setting is persistent across reboots.");
        System.err.println("");
        System.err.println("The 'restore' command when given just a restore token initiates a full-system");
        System.err.println("restore operation from the currently active transport.  It will deliver");
        System.err.println("the restore set designated by the TOKEN argument to each application");
        System.err.println("that had contributed data to that restore set.");
        System.err.println("");
        System.err.println("The 'restore' command when given a token and one or more package names");
        System.err.println("initiates a restore operation of just those given packages from the restore");
        System.err.println("set designated by the TOKEN argument.  It is effectively the same as the");
        System.err.println("'restore' operation supplying only a token, but applies a filter to the");
        System.err.println("set of applications to be restored.");
        System.err.println("");
        System.err.println("The 'restore' command when given just a package name intiates a restore of");
        System.err.println("just that one package according to the restore set selection algorithm");
        System.err.println("used by the RestoreSession.restorePackage() method.");
        System.err.println("");
        System.err.println("The 'run' command causes any scheduled backup operation to be initiated");
        System.err.println("immediately, without the usual waiting period for batching together");
        System.err.println("data changes.");
        System.err.println("");
        System.err.println("The 'wipe' command causes all backed-up data for the given package to be");
        System.err.println("erased from the given transport's storage.  The next backup operation");
        System.err.println("that the given application performs will rewrite its entire data set.");
        System.err.println("Transport names to use here are those reported by 'list transports'.");
    
    0 讨论(0)
  • 2021-01-30 13:18

    in Android 6.0, google added new feature called Auto Backup.

    when this option is on(default is on), Android system copies almost every directories and files that created by system, and upload it to user's google drive account.

    When user reinstalls app, android automatically restore app's data, no matter how it was installed(via Play store, adb install, initial device setup).

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

    android developers page : https://developer.android.com/guide/topics/data/autobackup.html

    0 讨论(0)
  • 2021-01-30 13:23

    The auto backup can be disabled by setting android:allowBackup="false" in AndroidManifest.xml

    0 讨论(0)
  • 2021-01-30 13:24

    I cam across this question when I was looking for a solution to a similar problem related to GreenDao - slightly more in depth answer here but basically if your on api 23 you'll need to set allowBackup to false to be able to depend on the databases being cleared when you uninstall

    https://stackoverflow.com/a/43046256/5298819

    0 讨论(0)
  • 2021-01-30 13:29
    1. Take a look at this SO answer:

    What happens to a Sqlite database when app is removed

    1. Does your DB work (aside from not deleting when removing the app)?

    2. If it isn't working properly, you may want to take a look at:

    http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html

    Although this is not necessarily related to your issue, you might want to consider creating an open() and close() for your DB and use a SQLiteOpenHelper object in each - in open(), you would use sqliteopenhelperObj.getWriteableDatabase() and in close() you would use sqliteopenhelperObj.close().

    http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html#close

    Edit:

    1. If you've downloaded files to your device during the process of testing an app, and you want to delete them, you can use the Device Monitor in Android Studio https://developer.android.com/tools/help/monitor.html There's a file manager that will allow you to see and edit files on your devices. You can also do this on the command line with the ADB (Android Debug Bridge) https://developer.android.com/tools/help/adb.html
    0 讨论(0)
提交回复
热议问题