Upload
elvin-heath
View
218
Download
0
Tags:
Embed Size (px)
Citation preview
Persistance
Android
Adding Persistance
• SQL Refresher• Understand how to create and migrate
SQLLite database with android APIs.– Get all tasks– Add a task– Update a task– Delete a task
Task Manager
Cast of Characters• SQLLiteDatabase- an API to a local SQLIte
database file.• SQLLiteOpenHelper – a utility class that make
it easy to create and maintain a local SQLite database.
Refactoring
• Code refactoring is a "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior“.
• http://en.wikipedia.org/wiki/Code_refactoring
SQLite in Android• SQLite is available on every Android device.
Using an SQLite database in Android does not require any database setup or administration.
• You only have to define the SQL statements for creating and updating the database. Afterwards the database is automatically managed for you by the Android platform.
• More help• http://answers.oreilly.com/topic/1914-what-is-
sqlite/
What is SQLite
• SQLite is an Open Source Database which is embedded into Android. SQLite supports standard relational database features like SQL syntax, transactions and prepared statements. In addition it requires only little memory at runtime (approx. 250 KByte).
• Unlike client–server database management systems, the SQLite engine has no standalone processes with which the application program communicates
Loading Task
Step one
Step One –Loading Tasks
How a SQLLite OpenHelper works
Creating a Database Table
Getting a data from Database
Loading Tasks Steps
Step 2
Adding a task
Adding Tasks
Adding Data to a Database
Step 3
• Updating a task
Step 3-Completing a task
Saving Data to Database
Completing a task
Step 4
• Deleting Task
Step 4-Remove Completed Task
Removing Data from Database
Remove Completed Tasks Steps
• DB desing and implementation.SQLITE DATABASE
APPLICATION
1)Open DB2)Close DB3)Insert and Remove objectsIn a type safe way
DBAdatper ClassThat enbales you to talk to Sqlite database
DBHelper Class
Create TablesUpgrade tables
DBHELPER Class tasks