0% found this document useful (0 votes)
3 views2 pages

SQLite Database Android Notes

SQLite is a lightweight, open-source relational database integrated into Android for local data storage and management. It allows for SQL operations and is created using the SQLiteOpenHelper class, which facilitates database creation and connection. SQLite supports full CRUD operations and is ideal for offline applications.

Uploaded by

humairahmad2004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

SQLite Database Android Notes

SQLite is a lightweight, open-source relational database integrated into Android for local data storage and management. It allows for SQL operations and is created using the SQLiteOpenHelper class, which facilitates database creation and connection. SQLite supports full CRUD operations and is ideal for offline applications.

Uploaded by

humairahmad2004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQLite Database and Database Creation &

Connection in Android
SQLite is a lightweight, open-source relational database built into Android. It is used to store and
manage structured data locally on a device and supports SQL operations such as CREATE,
INSERT, SELECT, UPDATE, and DELETE.

Features of SQLite
• Lightweight and fast
• Serverless database
• Stores data locally
• Supports SQL queries
• Reliable and secure
• Built into Android

Database Creation Using SQLiteOpenHelper


Create a helper class extending SQLiteOpenHelper. The onCreate() method creates tables and
onUpgrade() handles database version changes.
public class DBHelper extends SQLiteOpenHelper {
public DBHelper(Context context) {
super(context, "StudentDB", null, 1);
}

@Override
public void onCreate(SQLiteDatabase db) {
[Link]("CREATE TABLE Student(id INTEGER PRIMARY KEY, name TEXT)");
}
}

Database Connection
Writable Database:
SQLiteDatabase db = [Link]();

Readable Database:
SQLiteDatabase db = [Link]();

CRUD Operations
INSERT INTO Student VALUES(1,'Ali');
SELECT * FROM Student;
UPDATE Student SET name='Ahmed' WHERE id=1;
DELETE FROM Student WHERE id=1;

Advantages
• Lightweight and efficient
• No server required
• Easy integration with Android
• Suitable for offline applications
Conclusion
SQLite is the default relational database in Android. Database creation is done using
SQLiteOpenHelper and connections are established using getWritableDatabase() or
getReadableDatabase(). It supports complete CRUD operations and is widely used in Android
applications.

You might also like