Download presentation
Presentation is loading. Please wait.
Published byPaulina Hancock Modified over 9 years ago
1
SQLite Android Club 2015
2
SQLite About onCreate Insert Select Update Delete onUpdate
3
About SQLite Created in August 2000, by Richard Hipp For Guided missile destroyer
4
Why SQLite? Relational database No need for DBMS (Oracle, SQL Server) Light (takes only 0,3MB) One file (.sqlite or.db) Super Fast Text Search up to 1ms (6000+ms -> 150ms) ACID
5
Atomicity – all or nothing Consistency – valid state to another Isolation – one after the other Durability – no effect of power loss, crash, error
6
SQLite supported by Java JavaScript Objective-C Swift PHP C C# Ruby Python C++ And 30+ others
7
Create: example public class MyDatabase extends SQLiteOpenHelper{ SQLiteDatabase db; public MyDatabase(Context context) { super(context, "WIUT", null, 1); db = getWritableDatabase(); } @Override public void onCreate(SQLiteDatabase db) { String sql = "CREATE TABLE student(id TEXT,name TEXT);"; db.execSQL(sql); Log.d("ACLog", sql); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } }
8
Create: practice Create SQLiteOpenHelper class: StoreDatabase Database name: Store Version: 1 Create table: product(id TEXT, name TEXT, price INT)
9
INSERT: example public void insert(){ String sql = "INSERT INTO student(id, name) VALUES('8888','Kain Saridzawa‘)"; db.execSQL(sql); }
10
INSERT: practice Insert to product table: id: 1 name: Mineral water price: 1000
11
UPDATE: example public void update(){ String sql = "UPDATE student SET name='Joe Richard' WHERE id='8888'"; db.execSQL(sql); }
12
UPDATE: practice Update Mineral Water price to 1500
13
DELETE: example public void delete(){ String sql = "DELETE FROM student WHERE id='8888')"; db.execSQL(sql); }
14
DELETE: practice Delete Mineral Water from products table
15
Homework To-do list application Add task Update task Delete task Show task list
16
Questions? Any quesitons?
17
Thank you! Thank very much for your attention!
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.