Friday, July 8, 2022

Storage options in .NET MAUI

 .NET MAUI provides multiple storage options for caching data locally on a device.

The three most commonly used options for storing data locally in a .NET MAUI app are:

  • Preferences: Stores data in key-value pairs
  • File system: Stores loose files directly on the device through file system access
  • Database: Stores data in a relational database
Preferences are convenient when you're working with simple pieces of data, such as user selections.
Example:
c#
bool bUserDetails = ...; ... Preferences.Set("UserDetails", bUserDetails); ... var savedPreference = Preferences.Get("UserDetails", false);

The Preferences class also contains methods for determining whether a named preference exists (ContainsKey), deleting a preference (Remove), and removing all preference data (Clear).

No comments:

Post a Comment

LIveCharts2: Charts for Windows and web

Charts for Windows and web including .Net MAUI  LiveCharts - LiveCharts2 (lvcharts.com)