1

I'm looking for a way to store application data even after it has been uninstalled for both iOS and Android.

I'm currently using Application.Current.Properties from Xamarin.Forms. But the data is being erased upon uninstallation of the app.

So are there any ways that I could store my data so that it stays on the device after uninstallation?

Michael
  • 548
  • 6
  • 23
  • 2
    You would really need to store the data on a server to do this effectively. iOS does allow you to flag files for iCloud backup, which makes the data available on re-install (I think). – Jason Aug 19 '19 at 23:58
  • can't do without a remote server... You could ask for the user if he wants to backup its settings on google drive or iCloud for example. – Roubachof Aug 20 '19 at 09:19
  • for iOS you can store that value in Keychain – lalit Maheshwari Aug 20 '19 at 10:59
  • One option is to create a file of your values manually and save it in a publicly available location such as SD card. – VahidShir Aug 20 '19 at 11:05
  • https://learn.microsoft.com/en-us/xamarin/essentials/secure-storage?tabs=android may be helpful for you – lalit Maheshwari Aug 20 '19 at 11:10

2 Answers2

0

I have the same problem. In my case, I want to store identifierForVendor which it is id that is generated when installing the ios app. The problem of this Id is that it changes when uninstall the app and re-install it again. So I search for method that could be used to store information even after uninstalling the app. I found Xamarin.Essentials: Secure Storage, but after testing it appear that any value stored in the secure storage will be removed after uninstalling the app (for older ios systems, it may be not removed. However, there is no guarantee for the newer versions of ios).

I found a solution, which may not be practical. Create a file and store the information on it. There may be some disadvantages of this solution like:

  1. Be careful that this file may be readable by other apps, so if you plan to store sensitive information, you may encrypt the file.
  2. The file may be deleted after uninstalling the app if you store the file in the app storage path, so choose a path that will not be removed after uninstalling the app such as Download folder. However, you may encounter another problem is that the user may accidentally remove this file.
Ahmed Shamel
  • 1,982
  • 3
  • 24
  • 58
0

just try this.

App.xaml.cs

protected async override void OnStart()
{
    if (VersionTracking.IsFirstLaunchEver)
    {
        SecureStorage.Remove("token");
    }
    
    // proceed with OnStart() logic
}
Manoj Alwis
  • 1,337
  • 11
  • 24