android database sqlite tutorial & Example

26

In this tutorial I will introduce you with Android Database. I will use SQLite for the application for this tutorial. By the way, if you do not read previous tutorials, you may face some difficulties to understand the project.

What is SQLite?
SQLite is a relational database management system contained in a C programming library. In contrast to other database management systems, SQLite is not implemented as a separate process that a client program running in another process accesses. Rather, it is part of the using program.

SQLite is ACID-compliant and implements most of the SQL standard, using a dynamically and weakly typed SQL syntax that does not guarantee the domain integrity.

SQLite is a popular choice as embedded database 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, among others.[5] SQLite has bindings to many programming languages.

Step 1:
We are planning to create a book database for this application. We will create minimum amount of data input for simplicity. However, if you wish, you can extend this app as much as you want.

Lets create a Android project named, “RoidDatabase“. First of all need to create our view in “res/layoutlist_layout.xml and paste the following code for the layout.

We have our main activity layout in the same location. Now update your activity_main.xml as follows.

Step 2:

As we are planing to use SQLite, it is best practice to create a separate class to handle our database.

So, lets create a DatabaseHelperclass in the source folder.

Now we need to update our MainActivity class to handle our database input and output.

Now run your application with your emulator.

Android Database

Leave A Reply

Your email address will not be published.