Local storage can be needed for a number of things, user preferences, security tokens or caching downloaded data. What I will go through in this post is where and some ways to retain information locally on the device.
The common ones are:
- Keychain / KeyStore
- NSUserDefaults / SharedPreferences
- Internal (Application) Storage
- External Storage
- SQLite (though really just a file in storage)
For slightly more secure storage choose either
Your next best option is to always choose something in Internal Storage. Internal Storage means only the mobile app can access this data and not any other application. External Storage is available to any app on the phone and is not secure.
For secure storage have a look at Secure Storage on XLabs.
For internal settings storage have a look at the Settings Plugin for Xamarin. Its great for storing persistent non sensitive data.
If you need a more traditional relational database to store information the best option is SQLite. It is very popular and heavily used.
However if you want to use it in Xamarin Forms you will need to use a bit of dependency injection.
If you need your local SQLite database to be secured you can use SQLCipher. Its free if you have a Xamarin Enterprise License otherwise its a paid product. It encrypts the database locally so that even if the phone is stolen the database will still be secure.
Entity Framework is available for Xamarin, and can be used in iOS, Android and UWP. Have a look at Entity Framework Core with Xamarin.Forms.