Often, an app will need to backup it's data, especially if the data took time, effort or money to collect. The Android Backup Service provides a means of preserving data that is more complex than simple shared preferences or files.
In order to work with the backup API, we have to have registered our app package name with the Android Backup Service.
We do this on http://developer.android.com/google/backup/signup.html.
In this recipe, we will save a value to a file and read from a file. This can be a far more comprehensive set of actions on a larger dataset, but not necessary, for example:
Our app is not going to do much with the data, so we can save our single value to the filesystem as a basic write operation:
File.WriteAllText(dataPath, clickCount.ToString());
Additionally, to read the data on the app start, we will do a basic read:
if (File.Exists(dataPath)) { clickCount = int.Parse(File.ReadAllText(dataPath)); }
Now that we have the...