your app should not update the application settings file. you should have an additional setting file in the data folder that changes are made to. just add as the last setting file so it overrides the app settings.
Permanent MAUI config file survives update of application
Hello experts
I have a MAUI C# code below, for reading and writing a text file of user setting (like colors, ids, last state..) of MAUI application. Works perfect (development)! (MAUI Android and MAUI Windows)
But what happends with this setting file, if new app version is downloaded from the stores?
Android testings (internal/close) shows, that this settings file is deleted every time when new version of app is downloaded to the mobile from Google Play
How it works (production) on platforms Windows store, Tizen, Apple Store? Android Play store?
Can text file survives update of application?
Thanks a lot
W
private static string GetSettingsFileName
{
get
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Settings.txt");
}
}
public static void WriteSettings(string Content)
{
File.WriteAllText(GetSettingsFileName, Content);
}
public static string ReadSettings()
{
string fName = GetSettingsFileName;
if (File.Exists(fName))
{
return File.ReadAllText(fName);
}
else
return null;
}
1 additional answer
Sort by: Most helpful
-
Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 49,611 Reputation points Microsoft External Staff
2025-01-14T08:24:59.4133333+00:00 Hello,
Thanks for your feedback.
For private data such as user settings, Google provides a solution to back up the required items through the backup function.
Data backup overview | Identity | Android Developers mentions the backup of settings.
Settings data Make sure you also back up and restore settings data to preserve a returning user's personalized preferences on a new device. You can restore settings data even if a user doesn't log in to your app. You can back up settings that a user explicitly sets in your app's UI, as well as transparent data, such as a flag indicating whether a user has seen a setup wizard.
You could refer to the following documents to learn about the two main methods of implementing backup on the Android platform.
- Back up user data with Auto Backup | Identity | Android Developers
- Back up key-value pairs with Android Backup Service | Identity | Android Developers
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.