In this installment of the nine-part Mastering Xamarin.Forms Development series, Scott Peterson tackles data storage in cross-platform apps built with Xamarin.Forms.
- [Scott] The need for storage and storing data has been around for as long as software, and although the mechanisms have changed, the need has remained. I remember back in the early days of Visual Basic in the late 80's, it was essentially impossible to store data anywhere except in a local text file until Microsoft Access came on the scene. With the ubiquitous nature of devices, especially mobile devices, users now want their information whether they're on a phone, desktop, tablet, or even an Xbox and want their data available and synchronized across all these devices whether they're online or off.
The ability to store, access, and synchronize data across all devices, in any scenario, is another area where the Xamarin Forms platform really shines. I'm Scott J. Peterson, and this is Mastering Xamarin Forms Development: Data and Storage Strategies. The need for reliable, scalable, local, remote, and even offline synchronized storage is critical to app performance and honestly to the overall user experience. Since every platform stores data differently and has different policies around the way that data is accessed and managed, writing code for each one of these scenarios can be cumbersome and unwieldy.
The Xamarin Forms platform supports a wide variety of mechanisms to facilitate harmonized levels in variations of data and storage techniques. And again, just like everything in the Xamarin Forms platform, 95, 96, 98 percent of the code that you write will be shared across platforms. Things like having a local database, accessing local storage, accessing remote mobile services and online synchronization are really as simple as just writing a few lines of code in most scenarios.
Since your storage and database strategy is so critical to your app performance in the overall user experience of your app, the topics in this session could be an entire series on their own. But we're just going to focus on what I consider some of the more common primary data and storage strategies for Xamarin Forms development, and like most sessions in this series, we're going to be spending most of our time in Visual Studio Code, but let's take a look at some of the things that we're going to cover in this session. First, we're going to go over some basic data and storage concepts and talk about what I'm calling simple storage.
Typically this would mean local-device storage. We're also going to review some platform variations as well as reviewing the concept of dependency services since dependency services are critical to properly managing data and storage in your Xamarin Forms app, and then we're going to go into our Xamarin Forms app, Paper Boy, that we've been working on in this series, and take a quick look at how we would work with local storage. And then we're going to get into the real meat of this session, this idea of local databases, and talk specifically about using one of the coolest local database scenarios available, and that is Sequel Lite, and then we'll go into Visual Studio 2017 and update our Paper Boy app to actually integrate with Sequel Lite databases.
And then finally we're going to talk about one of the most powerful concepts available for Xamarin Forms development for iOS, Android, and Windows devices, and this is the ability to leverage Asure mobile services especially when it comes to Asure mobile data storage, using Asure mobile app, and integration with offline storage concepts, and then we're going to go back into our Xamarin Forms app Newsreader app and actually integrate remote databases with Asure mobile services and set it up for offline storage. And, as always, we'll finish up with some great next steps!
- Local storage and external storage options
- Dealing with platform differences
- Dependency services
- Working with local storage
- Using SQLite databases
- Working with a local database
- Working with remote databases and offline storage