2. WHY DATABASES ON ANDROID?
Common usage for a database
• Huge amounts of data
• Convenient query language to obtain data
• Accessed/modified by huge amount of users
Applications:
• backend for multi-tier web architecture,
• backend for business process architectures like SAP
• areas: banks, insurance companies, ...
Android
• Small scale architecture, little data, few applications ...
3. What is SQLite?
• SQLite is Open Source Database embedded into
Mobile Devices.
• SQLite supports SQL syntax, transactions and
prepared statements.
• SQLite consumes low memory approx. 250Kbyte.
4. SQLite
• Relational database with tables (DB schema)
• Popular embedded database, here: integrated in Android
• SQL interface + small memory footprint + decent speed
• Native API not JDBC
• Properties (from http://www.sqlite.org/different.html)
• Zero configuration and serverless
• Single database file & stable across platforms
• Compact, public domain, readable source code
• Manifest typing and variable length records
5. SQLite vs Content Provider
• SQLite
• Persistent storage of data
• Data accessible to a single application (the owner)
• Often wrapped by a Content Provider
• Content Provider
• Specialized type of data store to share data across apps
• Exposes standardized ways to retrieve/manipulate data
• Query with URI: <standard_prefix>://<authority>/<data_path>/<id>
• Examples: content://browser/bookmarks, content://contacts/people
• Built in
19. Add Button Click On MainActivity
Add another button name Show All Contact
in our activity_main.xml with id:btnAllContact
20. Add getContacts() in DatabaseAdapter Class
This method will return data from database in a
Arraylist.
21.
22. Make a Custom Adepter
As you have done before in ListView
Session
Create a CustomAdapter to bind data in
list adapter.
Then set the adapter in our listview.