Application Data Storage
Learn how to use built-in secure data storage in an MAUI app.
Any application type will need to store its data in some sort of storage. .NET MAUI applications are not an exception. We'll cover what storage options are available in .NET MAUI applications. We'll use the following project setup to provide us with some examples.
<?xml version = "1.0" encoding = "UTF-8" ?> <Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:SecureStorageDemo" x:Class="SecureStorageDemo.App"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources/Styles/Colors.xaml" /> <ResourceDictionary Source="Resources/Styles/Styles.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application>
Data storage supported by MAUI
Broadly speaking, there are three types of persistent data storage supported by MAUI:
Storage Type | Advantages | Disadvantages |
File storage |
|
|
Database storage |
|
|
Secure data storage |
|
|
There's also the ability to store data in memory. But we won't consider it as storage because the data does not persist once the application is closed and the memory is freed. There's also an ability to store data on the server. But again, we won't consider this, since the storage functionality isn't performed by the native application ... ...