1. Introduction
So far, all the techniques you have seen are useful for saving simple sets of data. To manage persistent data. For saving relational data, we can store the data in a file or in a database which is much more efficient. For example, if you want to store the test results of all the students in a school, it is much more efficient to use a database to represent them because you can use database querying to retrieve the results of specific students. Moreover, using databases enables you to enforce data integrity by specifying the relationships between different sets of data.
Android uses the SQLite database system. The database that you create for an application is only accessible to itself; other applications will not be able to access it.
In this lecture, you will learn how to programmatically create a SQLite database in your Android application. For Android, the SQLite database that you create programmatically in an application is always stored in the /data/data/
/databases folder.
2. Android SQLite Database
SQLite is a popular choice for embedded database software for local/client storage in application software such as web browsers. It is arguably the most widely deployed database engine, as it is used today by several widespread browsers, operating systems, and embedded systems (such as mobile phones), among others. SQLite has bindings to many programming languages. In Android, SQLite is one way of storing application data. It is a very lightweight database that comes with Android OS. In Android, integrating SQLite is a tedious task as it needs writing a lot of boilerplate code to store simple data.
? Introducing SQLite: SQLite is a relational database management system (RDBMS). It is well regarded, being:
? Open source
? Standards-compliant
? Lightweight
It has been implemented as a compact C library that’s included as part of the Android software stack. By providing functionality through a library, rather than as a separate process, each database becomes an integrated part of the application that created it. This reduces external dependencies, minimizes latency, and simplifies transaction locking and synchronization.