locked
What happens to data that is stored on an iOS device during an app update? RRS feed

  • Question

  • User355123 posted

    I have an app that I am writing that stores files in the Environment.SpecialFolder.Personal folder path.

    1.) is this the best practice to retain the data? 2.) Will the data get erased when I push an app update? 3.) Is there solid documentation on this topic?

    Thanks!

    Thursday, August 16, 2018 2:54 PM

Answers

  • User171749 posted
    1. I use it all the time, reading and writing to local files is really handy but I see a lot of people using Application.Current.Properties to store information instead.

    Check here for more information: https://codemilltech.com/persist-whatever-you-want-with-xamarin-forms/

    1. Nope, That's whats handy about writing to the local files is all data is stored until the user deletes the app. App updates keep the data.

    3 Not really. It's File.IO, It's nothing specific to Xamarin really.

    These are the methods I use if it helps.

    ```CSHARP // Write Information to a Local File public void WriteLocalFile(string FileName, string Data) { string filePath = Path.Combine(PersonalFolderPath, FileName); File.WriteAllText(filePath, Data); }

        // Load Information from a Local File
        public string LoadLocalFile(string FileName)
        {
            string filePath = Path.Combine(PersonalFolderPath, FileName);
            if (File.Exists(filePath)) return File.ReadAllText(filePath);
            return null;
        }
    

    ```

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, August 16, 2018 2:59 PM

All replies

  • User171749 posted
    1. I use it all the time, reading and writing to local files is really handy but I see a lot of people using Application.Current.Properties to store information instead.

    Check here for more information: https://codemilltech.com/persist-whatever-you-want-with-xamarin-forms/

    1. Nope, That's whats handy about writing to the local files is all data is stored until the user deletes the app. App updates keep the data.

    3 Not really. It's File.IO, It's nothing specific to Xamarin really.

    These are the methods I use if it helps.

    ```CSHARP // Write Information to a Local File public void WriteLocalFile(string FileName, string Data) { string filePath = Path.Combine(PersonalFolderPath, FileName); File.WriteAllText(filePath, Data); }

        // Load Information from a Local File
        public string LoadLocalFile(string FileName)
        {
            string filePath = Path.Combine(PersonalFolderPath, FileName);
            if (File.Exists(filePath)) return File.ReadAllText(filePath);
            return null;
        }
    

    ```

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, August 16, 2018 2:59 PM
  • User355123 posted

    @seanyda thanks!

    Thursday, August 16, 2018 3:03 PM