Uninstall/Reinstall App Every Time When Debugging Using Android Emulator

Nathan Sokalski 4,111 Reputation points
2021-03-25T02:47:40.787+00:00

When debugging my Xamarin.Android app using an Android emulator on Visual Studio 2019, I am trying to figure out how to control whether the app is completely reinstalled (any appdata or app files from the previous installation are removed). I can, of course, manually uninstall the app before starting the debugger, but that is very inefficient. I know that there is a way to do this, but I cannot seem to find it. How do I control whether data & files from the previous installation are retained between debugging sessions? If there is a good site with documentation on how to do this it would also be nice to know. Thanks.

Developer technologies .NET Xamarin
{count} votes

1 answer

Sort by: Most helpful
  1. JessieZhang-MSFT 7,716 Reputation points Microsoft External Staff
    2021-03-25T08:45:01.96+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    I am trying to figure out how to control whether the app is completely reinstalled (any appdata or app files from the previous installation are removed)

    For this ,we can check the official document Back up user data with Auto Backup .

    Auto Backup for Apps automatically backs up a user's data from apps that target and run on Android 6.0 (API level 23) or later. Android preserves app data by uploading it to the user's Google Drive—where it's protected by the user's Google Account credentials. The amount of data is limited to 25MB per user of your app and there's no charge for storing backup data. Your app can customize the backup process or opt out by disabling backups.

    By default, Auto Backup includes files in most of the directories that are assigned to your app by the system:

    Shared preferences files.
    Files saved to your app's internal storage, accessed by getFilesDir() or getDir(String, int).
    Files in the directory returned by getDatabasePath(String), which also includes files created with the SQLiteOpenHelper class.
    Files on external storage in the directory returned by getExternalFilesDir(String).

    Auto Backup excludes files in directories returned by getCacheDir(), getCodeCacheDir(), or getNoBackupFilesDir(). The files saved in these locations are only needed temporarily, or are intentionally excluded from backup operations.

    For more detais, you can check document: https://developer.android.com/guide/topics/data/autobackup

    Best Regards,

    Jessie Zhang

    ---
    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.