Backing up preferences and files to the cloud

Most apps will need some sort of backup for the various customizations that the app permits, especially if the app does not have a dedicated server to store those settings. The Android Backup Service provides a simple means of preserving data.

How to do it...

Adding backup support for shared preferences and files is very easy and very simple. Let's take a look at the following steps:

  1. Before we start, we have to register our app with the Android Backup Service: http://developer.android.com/google/backup/signup.html

    On the form, enter the application package name and click on Register.

  2. Make a note of the key that is provided and create a [MetaData] attribute in our app with the value being the key:
    [assembly: ...

Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.