Most mobile applications will have data that they may wish to persist across application restarts and also device restarts. What are the various ways that are available in NativeScript to persist data within their built-in storage on their mobile device. Let's look at the various approaches that we can use within our NativeScript application. Next. NativeScript support for Data Storage comes in many different thoughts. So, we have several methods that we can use for persistent data, depending upon the amount of data that we want to persist. And also depending upon the kind of operations that we may want to perform on the data that is stored on the device. So simple data can be stored using application settings, or if you prefer, you can use the file system on the device to persist the data in a file. You can also use structured data storage in the form of databases. Either using an SQL-based database like SQLite or a document or NoSQL document based database like Couchbase Lite. We'll look at each of these in little more detail in the next few slides. Application Settings provide a simple way of persisting data within your application. As the name implies this is typically used for saving settings within your application. If you are familiar with the android chip preferences, the application settings is similar to Android shared preferences. So it allows you to save and restore small amounts of data within your application. This is where we will leverage the application settings module in order to help us to save and retrieve the data. The data itself is persisted using a key value pair storage. So you purchase the data by specifying the key and the corresponding value. And then you can retrieve the data by specifying the key and then obtaining the value from the storage. And the various kinds of data that can be persisted include boolean, number, and string data types. Um the data access itself using application settings is supported using the set and the get methods. So you can use methods like setString and then specify the key and the value for that string that you want to store. And you can retrieve the string by saying getString and key. You can also supply a default value. In case that value doesn't exist in the application storage then the default value will be supplied instead. You can also check to see if the key exists using the has key. You can remove by uh specifying the key. You can clear the entire application storage by calling the clear method. So this is a very simple way of persisting small amounts of data within your application. If the application settings doesn't satisfy your requirement, then you can result to using files. You can read and write data from the files. As you realize both Android and iOS have a built-in file system and this is abstracted and made available within your NativeScript application with a high-level abstraction for the file system and entities like the files, the folders, the paths to the folders, the separators, and the extensions and so on. So this is where you will import the file system module to make use of files and file storage in your application. So you can create, read, update, and delete files that you can store on your device. If you wish to store structured data within any other application. Also support operations like creating the data then databases provides the most optimal way of storing those data. So for repeated unstructured data you would need to result to databases. And when you have databases they will support the typical CRUD operations the Create, Read, Update and Delete operations on either records or documents depending on the kind of database that you are using. If you use database in your application then it is best to define a service that manages the access to the database and then exports an API that is more convenient to use within the components of your needs of your application. And this is the approach that we will adopt in the exercise that follows this lecture. If you would like to store your data in a relational database then both Android and iOS support the SQLite Database. So what exactly is an SQLite Database? The SQLite Database is a light weight database that supports Atomic operations, and the Stable, Independent and a very small footprint for their database use within your application itself. It supports many of the common SQL-like commands so if you're familiar with the SQL or the Structured Query Language then you would be easily able to define your database operations using SQL like syntax. Of course, only a subset of the SQL operations are supported by you SQLite. Fortunately, SQLite is supported both by Android and iOS baked into their native platforms. So both Android and iOS have native support for SQLite. So this is to our advantage. Within your NativeScript application. If you want to make use of SQLite then you should install their corresponding NativeScript SQLite plugin. And then that will enable you to access their built-in SQLite Database Support within both the Android and the iOS platform. If you are more happier with a NoSQL database or a document like database then Coachbase lite is an option that is available for you. So this supports a NoSQL like document database which stores the data in the form of embedded JSON documents in your database. On the server side for example in the last course we have look at MongoDB which is yet another NoSQL database but that is supported on the server side. Couchbase Lite is supported on your mobile platform. The advantage of using Couchbase Lite is that if you have a server side with the full fledged Couchbase server uh running a no SQL database then synchronization between your Couchbase Lite database on your device and the server side Couchbase database is very easy to be established. And with the Couchbase Lite that is fairly straight forward. The use of Couchbase Lite within you're NativeScript application is through their NativeScript Couchbase Lite pluggin that you will install to get access to their Couchbase database. And this supports various methods on your database so you can get, create, update, and delete documents in your database. Creating support is also available through map reduce views that are created using the create view method and also the execute query method. We will see the use of these methods in the exercise that will follow this lecture. With this quick understanding of NativeScript storage support. Let's move on to the two exercises. In the first exercise we have looked at the use of application settings in order to store and retrieve the login credentials for the user. Thereafter in their second exercise in this lesson, we'll look at the use of Couchbase Lite based database. Then we will persist the favorites for our user such that even when you restart your application or restart your device the favorites that you save will be persistent across application and device restarts.