The document provides information on SQLite database in Android. It discusses that SQLite is a lightweight database that is available on every Android device and supports SQL syntax, transactions and statements. It has advantages like being very lightweight, requiring little memory and being automatically managed by Android. SQLite supports three main data types - TEXT, INTEGER, REAL. The SQLiteOpenHelper class is used to manage database creation and versioning by overriding onCreate() and onUpgrade() methods. The SQLiteDatabase class provides methods to open, insert, update, close databases. ContentValues are used to insert or update database entries as key-value pairs. A query returns a Cursor object to access result rows without loading all data into memory. Content providers manage centralized data access for
2. What is SQLite?
• Open Source Database
• SQLite is available on every Android device
• It supports standard relational database features like
– SQL syntax
– transactions
– SQL statements
3. Advantages of Using SQLite
• Very light weight database
• Requires very little memory
– Approx. 250KB
• SQLite Database is automatically managed by
Android Platform
5. SQLite Data Types
• SQLite supports only three data types
– TEXT (like String)
– INTEGER (like int)
– REAL (like double)
• SQLite itself does not validate the data types
7. SQLiteOpenHelper Class
• It is a helper class used to manage database creation
and version management
• We override the onCreate() and onUpgrade()
methods in this class
• These methods are automatically called by the
framework
8. SQLiteOpenHelper Class
• onCreate()
• This method is called
– if the database does not exists
• onUpgrade()
• This method is called
– if the database version is increased
10. SQLiteDatabase Class
• SQLiteDatabase is the base class for working with a
SQLite database
• It provides various methods like :
– Open()
– Insert()
– Update()
– Close()
12. ContentValues
• ContentValues are used to insert or update database
entries
• Records are stored as key-value pair in
ContentValues
• Where :
– Key represents Column-Id
– Value represents data for the Column-Id
14. Cursor
• A query returns a Cursor object
• This Cursor points to a single row of the result
fetched by the query
• Benefit :
– No need to load all data into memory
16. Content Providers-What are they
• A content provider manages access to a central repository of
data.
• content providers are primarily intended to be used by other
applications, which access the provider using a provider client
object.
• An application accesses the data from a content provider with
a ContentResolver client object
17. Content Providers Continued:
• The ContentProvider uses the path part of the content URI to
choose the table to access
• Add a content provider uses permission to the manifest
• Provides methods to insert,update,delete,query