O'Reilly logo

Cross-platform UI Development with Xamarin.Forms by Paul F. Johnson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Constructing a persistent and cross-platform settings system

Let's consider what we know from our previous examples:

  • All the system settings use a key and value system to store the names
  • The methods of entry and retrieval are different
  • Android cannot store all types of primitive (doubles are excluded), but it can store collections

From the PCL side, we need an interface to the main platform code:

public interface IUserSettings
{
  void SetSetting<T>(string name, T value);
  
  T GetSetting<T>(string name);
}

Unlike the example used with Android, we will not pass an enumeration as a second or third parameter.

After this, the platform implementations are required. The full source for this can be found in the Chapter 11 source code archive. I'll demonstrate how ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required