PRESENTED BY;
KAWOOYA MUSTAFHA
STELLA ANYEKO
SHARAFUDIN LUTALO
SQLITE DATABASE
Introductory part about SQLITE
 SQLite is a self-contained, server less, and zero-configuration relational
database management system (RDBMS).
 It is designed to be embedded into applications, providing a lightweight
and efficient way to store and manage data.
 SQLite is a popular choice for many applications, including mobile apps,
desktop applications, embedded systems, and web applications
Key Features of SQLITE
 Server less
 Zero-configuration
 Relational database: SQLite supports standard relational database
features, including:
- Tables
- Indexes
- Views
- Transactions
Key Features of SQLITE
 ACID compliance: SQLite follows the Atomicity, Consistency, Isolation, and
Durability (ACID) principles, ensuring that database transactions are
processed reliably
 Atomicity
 Consistency
 Isolation
 Durability
Advantages of SQLITE
 Lightweight
 Fast
 Easy to use
 Low overhead
Creating and opening Database
 Creating and Opening a Database
 The SQLiteOpenHelper class helps in database management.
 onCreate() → Called when the database is created for the first time.
Creating Tables
• A table in SQLite consists of columns (fields) with specific data types.
Common Data Types in SQLite: INTEGER → Stores whole numbers.
• TEXT → Stores text values.
• REAL → Stores floating-point numbers.
• BLOB → Stores binary data.
Creating tables code
public void onCreate(SQLiteDatabase db) {
String CREATE_TABLE = "CREATE TABLE students (id INTEGER PRIMARY KEY,
name TEXT, age INTEGER)";
db.execSQL(CREATE_TABLE);
}
Inserting Data
 Data is inserted using the insert() method or raw SQL queries.
Inserting Data Codes
public void insertStudent(String name, int age) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put("name", name);
values.put("age", age);
db.insert("students", null, values);
db.close();
}
Retrieving Data
 Data is retrieved using the query() method or raw SQL queries.
Retrieving Data Code
public Cursor getAllStudents() {
SQLiteDatabase db = this.getReadableDatabase();
return db.rawQuery("SELECT * FROM students", null);
}
Deleting Data
 The delete() method removes specific records.
Deleting Data Code
public void deleteStudent(int id) {
SQLiteDatabase db = this.getWritableDatabase();
db.delete("students", "id=?", new String[]{String.valueOf(id)});
db.close();
}

presentation ndejje uni Group 5 network application_042029.pptx

  • 1.
    PRESENTED BY; KAWOOYA MUSTAFHA STELLAANYEKO SHARAFUDIN LUTALO SQLITE DATABASE
  • 2.
    Introductory part aboutSQLITE  SQLite is a self-contained, server less, and zero-configuration relational database management system (RDBMS).  It is designed to be embedded into applications, providing a lightweight and efficient way to store and manage data.  SQLite is a popular choice for many applications, including mobile apps, desktop applications, embedded systems, and web applications
  • 3.
    Key Features ofSQLITE  Server less  Zero-configuration  Relational database: SQLite supports standard relational database features, including: - Tables - Indexes - Views - Transactions
  • 4.
    Key Features ofSQLITE  ACID compliance: SQLite follows the Atomicity, Consistency, Isolation, and Durability (ACID) principles, ensuring that database transactions are processed reliably  Atomicity  Consistency  Isolation  Durability
  • 5.
    Advantages of SQLITE Lightweight  Fast  Easy to use  Low overhead
  • 6.
    Creating and openingDatabase  Creating and Opening a Database  The SQLiteOpenHelper class helps in database management.  onCreate() → Called when the database is created for the first time.
  • 7.
    Creating Tables • Atable in SQLite consists of columns (fields) with specific data types. Common Data Types in SQLite: INTEGER → Stores whole numbers. • TEXT → Stores text values. • REAL → Stores floating-point numbers. • BLOB → Stores binary data.
  • 8.
    Creating tables code publicvoid onCreate(SQLiteDatabase db) { String CREATE_TABLE = "CREATE TABLE students (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)"; db.execSQL(CREATE_TABLE); }
  • 9.
    Inserting Data  Datais inserted using the insert() method or raw SQL queries.
  • 10.
    Inserting Data Codes publicvoid insertStudent(String name, int age) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues values = new ContentValues(); values.put("name", name); values.put("age", age); db.insert("students", null, values); db.close(); }
  • 11.
    Retrieving Data  Datais retrieved using the query() method or raw SQL queries.
  • 12.
    Retrieving Data Code publicCursor getAllStudents() { SQLiteDatabase db = this.getReadableDatabase(); return db.rawQuery("SELECT * FROM students", null); }
  • 13.
    Deleting Data  Thedelete() method removes specific records.
  • 14.
    Deleting Data Code publicvoid deleteStudent(int id) { SQLiteDatabase db = this.getWritableDatabase(); db.delete("students", "id=?", new String[]{String.valueOf(id)}); db.close(); }