Android Programming - What is SQLite in Android



Click to watch


Android Programming - What is SQLite in Android









What is SQLite in Android ?

SQLite is an opensource SQL database.

SQLite in Android:

SQLite embedded into Android app (Android device - database on local device). SQLite has built-in Android SDK. This is a special characteristic of SQLite in Android. SQLite is private database means database that you created for one application, only application that access and use.

The four most important basic operations when working with SQLite database

1) How to create / delete a SQLite database in Android
2) How to create / delete tables in SQLite
3) How to add / edit / delete data in the table
4) How to query the data in the table.

Where is the strong point of the SQLite database?
...
...
...


To understand the SQLite we will do simple example following:

Assuming you want to store the information of a person which includes: Id, Name, Phone Number. We will create a table Contact the following:

Table Contacts

First, we will create a project SQLiteAndroidTutorial
Next, create 2 classes. Contact.java class used to set/get data in Contacts table. DatabaseHandler.java class inherits SQLiteOpenHelper class is used to manipulate the database as: Create database, Open database, ..., Close database.

package com.example.sqliteandroidtutorial  

public class Contact { 

// member variables
int id;
String name, phoneNumber;

// Empty construct
public Contact () {
}

// Constructor 3 parameters
public Contact (int id, String name, String phoneNumber) {

this.id = id;
this.name = name;
this.phoneNumber = phoneNumber;

}

// Constructor 2 parameters
public Contact (String name, String phoneNumer) {

this.name = name;
this.phoneNumber = phoneNumber;

}





Share on Google Plus

About Unknown

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment