9 Persistence - SQLite CSNB544 Mobile Application Development Thanks to Utexas Austin.

Slides:



Advertisements
Similar presentations
Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
Advertisements

1 After completing this lesson, you will be able to: Create a database. Create a table using the Table Wizard. Create and modify a table in Design view.
MS-Access XP Lesson 1. Introduction to MS-Access Database Management System Software (DBMS) Store data in databases Database is a collection of table.
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
Access Lesson 2 Creating a Database
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Access Tutorial 1 Creating a Database
Concepts of Database Management Sixth Edition
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
Database Updates Made Easy In WebFocus Using SQL And HTML Painter Sept 2011 Lender Processing Services 1.
SQLLite and Java CS-328 Dick Steflik. SQLLite Embedded RDBMS ACID Compliant Size – about 257 Kbytes Not a client/server architecture –Accessed via function.
CS378 - Mobile Computing Persistence - SQLite. Databases RDBMS – relational data base management system Relational databases introduced by E. F. Codd.
Access Tutorial 10 Automating Tasks with Macros
Data Persistence in Android
SQLite Database. SQLite Public domain database – Advantages Small (about 150 KB) – Used on devices with limited resources Each database contained within.
Unit J: Creating a Database Microsoft Office Illustrated Fundamentals.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 4 – Creating New.
Concepts of Database Management Seventh Edition
Lesson No:9 MS-Word Tools, Mail Merge and working with Tables CHBT-01 Basic Micro process & Computer Operation.
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
® Microsoft Access 2010 Tutorial 1 Creating a Database.
CODD’s 12 RULES OF RELATIONAL DATABASE
Microsoft Access 2010 Building and Using Queries.
Lesson 2.  To help ensure accurate data, rules that check entries against specified values can be applied to a field. A validation rule is applied to.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
Address Book App 1. Define styles   Specify a background for a TextView – res/drawable/textview_border.xml.
Concepts of Database Management Seventh Edition
MS-Word XP Lesson 9. Mail Merge The Mail Merge feature combines a list of data, typically name and address that is contained in one file with a document.
Chapter 17 Creating a Database.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 33 Advanced Java.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 8 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 8 Creating.
® Microsoft Office 2013 Access Creating a Database.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
Microsoft Access. Microsoft access is a database programs that allows you to store retrieve, analyze and print information. Companies use databases for.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. Adding a new field 1Right click the table name and select design view 2Type the field information at the end.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Microsoft Excel 2003 Illustrated Complete Data with Other Programs Exchanging.
Persistence Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.
Mobile Software Development ISCG 7424 Department of Computing UNITEC John Casey and Richard Rabeder SQLite and Permissions.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
INTRODUCTION TO ACCESS. OBJECTIVES  Define the terms field, record, table, relational database, primary key, and foreign key  Create a blank database.
SQLite DB Storing Data in Android RAVI GAURAV PANDEY 1.
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
Android - SQLite Database 12/10/2015. Introduction SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
COMPREHENSIVE Access Tutorial 1 Creating a Database.
Address Book App 1 Fall 2014 CS7020: Game Design and Development.
CHAPTER 9 File Storage Shared Preferences SQLite.
Programming with Microsoft Visual Basic 2012 Chapter 14: Access Databases and SQL.
By: Eliav Menachi.  On Android, all application data (including files) are private to that application  Android provides a standard way for an application.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Introduction to Database Programming with Python Gary Stewart
Copyright © 2014 Pearson Canada Inc. Ext. 5b-1 Copyright © 2014 Pearson Canada Inc. Application Extension 5b Using Microsoft Access Part 2: Using Information.
Data Storage in Android Димитър Н. Димитров. Why talk about data? Why not 3D graphics or network connectivity? Data as fundamental term in computer science.
1. 2 The Address Book app provides convenient access to contact information that’s stored in a SQLite database on the device. You can: scroll through.
CS371m - Mobile Computing Persistence - SQLite. 2 In case you have not taken 347: Data Management or worked with databases as part of a job, internship,
SQLite in Android Landon Cox March 2, 2017.
Practical Office 2007 Chapter 10
Mobile Applications (Android Programming)
Android Application SQLite 1.
Mobile Application Development Chapter 5 [Persistent Data in Android]
Access Creating a Database
Chapter 4 MS ACCESS DATABASE.
Access Creating a Database
CS371m - Mobile Computing Persistence - SQLite.
Mobile Computing With Android ACST 4550 Android Database Storage
ListView A view that shows items in a vertically scrolling list. The items come from the ListAdapter associated with this view. ListAdapter is used to.
Mobile Programming Dr. Mohsin Ali Memon.
Presentation transcript:

9 Persistence - SQLite CSNB544 Mobile Application Development Thanks to Utexas Austin

Databases RDBMS – relational data base management system Relational databases introduced by E. F. Codd – Turing Award Winner Relational Database – data stored in tables – relationships among data stored in tables – data can be accessed and view in different ways 2

SQL and SQLite Structured Query Language programming language to manage data in a RDBMS SQLite implements most, but not all of SQL SQLite becomes part of application 3

SQLite and Android Databases created with or for application accessible by name to all classes in application, but none outside application Creating database: – create subclass of SQLiteOpenHelper and override onCreate() method – execute SQLite command to create tables in database 4

Creating Database Example: Movie Rating App Stores user ratings Not a complex example Database only has one table Adapted from Deitel Address Book Application AndroidforProgrammers/tabid/3606/Default.aspx 5

Classes 6 MovieRaterActivity Starting Activity Displays List of RatedMovies AddEditRating Add or Edit Rating menu - Add Rating ViewRating Show Rating and Information click on Movie Title menu - Edit Rating menu - Delete Rating Row remove from database DatabaseConnector Interact With Database

MovieRaterActivity ScrollView Queries data base for all names / titles Clicking on Title brings up that rating in ViewRating 7

Menu for MovieRaterActivity Only one menu option button to Add Rating Brings up AddEditRating Activity 8

ViewRating Pulls all data from database for row based on name / title Use of a RatingBar ViewRating has its own Menu 9

ViewRating Menu Edit Rating starts AddEditRating activity and populates fields with these values (place in Extras) Delete Rating brings up confirmation Dialog 10

AddEditRating Add Rating – fields are blank Consider adding a button for date picker instead of typing data Must enter title / name other fields can be blank 11

AddEditRating When title clicked in main Activity, MovieRaterActivity Make changes and click save 12

DatabaseConnector Class Start of class 13

DatabaseConnector Class 14

Creating Database Via an inner class that extends SQLiteOpenHelper 15

Creating Database Money method 16

Creating Database String is a SQLite command ratings is name of table table has seven columns – _id, name, genre, dateSeen, tag1, tag2, rating storage classes for columns: – TEXT, INTEGER, REAL – also NULL and BLOB _id is used as primary key for rows 17

Database on Device can pull database and view sqlitebrowser is a good tool 18

Inserting Data ContentValues are key/value pairs that are used when inserting/updating databases Each ContentValue object corresponds to one row in a table _id being added and incremeneted automatically 19

Inserting Data In AddEditRating When save button clicked 20

Inserting Data In DatabaseConnector 21 nullCoumnHack, for inserting empty row

Updating Data In AddEditRating When save button clicked notice id added 22

Updating Data In DatabaseConnector 23

Query Data Getting a single row by _id – in order to populate ViewRating 24

Query Data Get all rows To populate the ListView in the MovieRaterActivity only getting _id and name columns 25

Deleting Data Menu Option in ViewRating 26

Database Cursor Cursor objects allow random read - write access to the result of a database query Ours only used to read the data Use a CursorAdapter to map columns from cursor to TextView or ImageViews defined in XML files 27

Database Connection Recall: 28

MovieRaterActivity Rating Adapter is a CursorAdapter from onCreate method 29

Updating Cursor Cursor initially null separate task to create cursor and update adapter 30

Asynch Task 31

Clicking on Item in List _id not displayed but still part of entry in list -> use _id to get back to database row 32

Other Cursor Options moveToPrevious getCount getColumnIndexOrThrow getColumnName getColumnNames moveToPosition getPosition 33

Possible Upgrades Add functionality to – show all movies that share a particular genre – movies from a date range – shared tags Just more complex data base queries 34