07. Data Storage

Size: px
Start display at page:

Download "07. Data Storage"

Transcription

1 07. Data Storage

2 Agenda Data storage options How to store data in key-value pairs How to store structured data in a relational database 2

3 Data Storage Options Shared Preferences Store private primitive data in key-value pairs. Internal Storage Store private data on the device memory. External Storage Store public data on the shared external storage. SQLite Databases Store structured data in a private database. Network Connection Store data on the web with your own network server. 3

4 SQL 4

5 Introduction to SQL SQL stands for Structured Query Language SQL is a computer language for storing manipulating retrieving data stored in relational database SQL Commands Data Definition Language (DDL) CREATE, ALTER, DROP Data Manipulation Language (DML) SELECT, INSERT, UPDATE, DELETE Data Control Language (DCL) GRANT, REVOKE 5

6 Create Table The CREATE TABLE statement is used to create a table in a database CREATE TABLE table_name ( column1 datatype, ); column2 datatype CREATE TABLE tblemployee( ID INT department VARCHAR(20), salary DECIMAL(18,2) ); 6

7 Drop Table The DROP TABLE statement is used to delete a table DROP TABLE table_name; DROP TABLE tblemployee; 7

8 Select Data From Table The SELECT statement is used to select data from a database SELECT column1, column2...columnn FROM table_name; WHERE conditions GROUP BY column1, column2 HAVING conditions ORDER BY column1{asc DESC} 8

9 Select Example 1 ID Department Salary 100 HR IT HR IT 1400 SELECT ID, department FROM tblemployee WHERE ID=101; ID Department 101 IT 9

10 Select Example 2 ID Department Salary 100 HR IT HR IT 1400 SELECT ID, salary FROM tblemployee WHERE Department=IT ORDER BY DESC; ID Salary

11 Select Example 3 ID Department Salary 100 HR IT HR IT 1400 SELECT department, sum(salary) FROM tblemployee GROUP BY department; Department Salary HR 2250 IT

12 Select Example 4 ID Department Salary 100 HR IT HR IT 1400 SELECT department, sum(salary) FROM tblemployee GROUP BY department HAVING sum(salary)>2500; Department Salary IT

13 Insert Data The INSERT INTO statement is used to insert new records in a table INSERT INTO table_name (column1, column2,...columnn) VALUES (value1, value2,...valuen) Example INSERT INTO tblemployee (ID, department,salary) VALUES (105, IT, 1400) 13

14 Update Data The UPDATE statement is used to update records in a table UPDATE table_name SET column1=value1, column2=value2 WHERE condition Example UPDATE tblemployee SET salary=2000 WHERE ID=101 14

15 Delete Data The DELETE statement is used to delete records in a table DELETE FROM table_name WHERE condition Example DELETE FROM tblemployee WHERE ID=101 15

16 SQLite 16

17 What is SQLite? SQLite is a open source SQL database that stores data to a text file on a device Android comes in with built in SQLite database implementation SQLite supports all the relational database features like SQL syntax, transactions and prepared statements 17

18 SQLite Data Types NULL The value is a NULL value. INTEGER The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value. REAL The value is a floating point value, stored as an 8-byte IEEE floating point number. TEXT The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE). BLOB The value is a blob of data, stored exactly as it was input 18

19 SQLite in Android SQLite is embedded into every Android device. Using an SQLite database in Android does not require a setup procedure or administration of the database. 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. The database is by default saved in the directory DATA/data/APP_NAME/databases/FILENAME. 19

20 SQLite in Android The android.database package contains all necessary classes for working with databases. The android.database.sqlite package contains the SQLite specific classes. To create and upgrade a database in your Android application you create a subclass of the SQLiteOpenHelper class 20

21 SQLiteOpenHelper A helper class to manage database creation and version management You create a subclass implementing oncreate(sqlitedatabase) Called when the database is created for the first time onupgrade(sqlitedatabase, int, int) Called when the database needs to be upgraded 21

22 SQLiteOpenHelper public class DatabaseHandler extends SQLiteOpenHelper { /* Constructor */ public DatabaseHandler(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } /* Create table on public void oncreate(sqlitedatabase db) { } /* Update table on public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { } } 22

23 SQLiteOpenHelper Parameters context name factory to use to open or create the database name of the database file, or null for an in-memory database to use for creafng cursor objects, or null for the default version - number of the database (starfng at 1) - if the database is older, onupgrade(sqlitedatabase, int, int) will be used to upgrade the database - if the database is newer, ondowngrade(sqlitedatabase, int, int) will be used to downgrade the database 23

24 Create and Upgrade Table public class DatabaseHandler extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; //-- Database Version private static final String DATABASE_NAME = "contactsdb ; //-- Database Name private static final String TABLE_CONTACTS = "tblcontacts ; //-- Contacts table name private static final String COL_KEY_ID = "id ; //-- ID Column private static final String COL_NAME = "name"; //-- Name Column private static final String COL_PHONE = "phonenumber ; //-- Phone Column public DatabaseHandler(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); public void oncreate(sqlitedatabase db) { String CREATE_CONTACTS_TABLE = "CREATE TABLE " + TABLE_CONTACTS + "(" + COL_KEY_ID + " INTEGER PRIMARY KEY," + COL_NAME + " TEXT," + COL_PHONE + " TEXT" + ")"; db.execsql(create_contacts_table); public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { //-- drop older table if existed db.execsql("drop TABLE IF EXISTS " + TABLE_CONTACTS); //-- create tables again oncreate(db); } 24

25 SQLiteOpenHelper Methods SQLiteDatabase getreadabledatabase() Create and/or open a database for read Returns a database object valid until getwritabledatabase() or close() is called. SQLiteDatabase getwritabledatabase() Create and/or open a database that will be used for reading and writing Returns a read/write database object valid until close() is called 25

26 SQLiteDatabase Exposes methods to manage a SQLite database. SQLiteDatabase has methods to create delete execute SQL commands perform other common database management tasks. 26

27 void execsql () Execute a single SQL statement that is NOT a SELECT or any other SQL statement that returns data. Parameters sql the SQL statement to be executed. MulFple statements separated by semicolons are not supported 27

28 Cursor rawquery () Runs the provided SQL and returns a Cursor over the result set. Parameters sql the SQL query selecfonargs You may include?s in where clause in the query, which will be replaced by the values from selecfonargs Return A Cursor object, which is posifoned before the first entry 28

29 rawquery Example public List<Contact> getallcontacts() { SQLiteDatabase db = this.getwritabledatabase(); List<Contact> contactlist = new ArrayList<Contact>(); String selectquery = "SELECT * FROM " + TABLE_CONTACTS; //-- select all query //-- run query on db Cursor cursor = db.rawquery( selectquery, // the SQL query. null); } //-- loop through all rows and adding to list if (cursor.movetofirst()) { //-- Move the cursor to the first row do { Contact contact = new Contact(); contact.setid(cursor.getint(0)); contact.setname(cursor.getstring(1)); contact.setphonenumber(cursor.getstring(2)); } contactlist.add(contact); //-- add contact to list } while (cursor.movetonext()); // Move the cursor to the next row //-- close resources cursor.close(); db.close(); return contactlist; //-- return contact list 29

30 long insert () Insert a row into the database Parameters table nullcolumnhack values the table to insert the row into opfonal; may be null this map contains the inifal column values for the row. The keys should be the column names and the values the column values Return the row ID of the newly inserted row, or -1 if an error occurred 30

31 insert Example public long addcontact(contact contact) { // SQL Statement: INSERT tblcontacts (name,phonenumber) VALUES ('a','1') SQLiteDatabase db = this.getwritabledatabase(); // Create ContentValues to pass insert method ContentValues values = new ContentValues(); values.put(col_name, contact.getname()); values.put(col_phone, contact.getphonenumber()); //-- insert new contact row long result = db.insert( TABLE_CONTACTS, // the table to insert the row into null, values); // this map contains the column values for the row. //-- close database connection db.close(); return result; } 31

32 Cursor query () Query the given table, returning a Cursor over the result set. Parameters table columns selecfon selecfonargs The table name to compile the query against A list of which columns to return. Passing null will return all columns A filter declaring which rows to return, forma\ed as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given table You may include?s in selecfon, which will be replaced by the values from selecfonargs, in order that they appear in the selecfon 32

33 Cursor query () Parameters groupby having orderby A filter declaring how to group rows, forma\ed as an SQL GROUP BY clause (excluding the GROUP BY itself). Passing null will cause the rows to not be grouped A filter declare which row groups to include in the cursor, if row grouping is being used, forma\ed as an SQL HAVING clause (excluding the HAVING itself). How to order the rows, forma\ed as an SQL ORDER BY clause (excluding the ORDER BY itself). Return A Cursor object, which is posifoned before the first entry 33

34 query Example public Contact getcontact(int id) { // SELECT id,name,phonenumber FROM tblcontacts SQLiteDatabase db = this.getreadabledatabase(); Contact contact = new Contact(); Cursor cursor = db.query( TABLE_CONTACTS, // The table name to compile the query against. new String[] { COL_KEY_ID, COL_NAME, COL_PHONE }, // A list of columns COL_KEY_ID + "=?, // SQL WHERE clause new String[] { String.valueOf(id) }, // selectionargs for WHERE clause null, // SQL GROUP BY null, // SQL HAVING clause null); // SQL ORDER BY clause } } if (cursor = null) { //-- Check cursor object for null cursor.movetofirst(); //-- Move the cursor to the first row contact.setid(cursor.getint(0)); //-- read id (0th col) from cursor contact.setname(cursor.getstring(1)); //-- read name (1th col) from cursor contact.setphonenumber(cursor.getstring(2)) //-- read phone (2th col) from cursor cursor.close(); //-- close cursor db.close(); //-- close database connection return contact; 34

35 int update () Update rows in the database. Parameters table values whereclause whereargs the table to update in a map from column names to new column values the opfonal WHERE clause to apply when updafng. Passing null will update all rows You may include?s in the where clause, which will be replaced by the values from whereargs Return the number of rows affected 35

36 update Example public int updatecontact(contact contact) { SQLiteDatabase db = this.getwritabledatabase(); // Create ContentValues to pass update method ContentValues values = new ContentValues(); values.put(col_name, contact.getname()); values.put(col_phone, contact.getphonenumber()); int result = db.update( TABLE_CONTACTS, // table values, // values COL_KEY_ID + " =?, // whereclause new String[] { String.valueOf(contact.getId()) }); // whereargs } //-- close resources db.close(); return result; 36

37 int delete () Delete rows in the database Parameters table whereclause whereargs the table to delete from the opfonal WHERE clause to apply when delefng. Passing null will delete all rows You may include?s in the where clause, which will be replaced by the values from whereargs Return the number of rows affected if a whereclause is passed in, 0 otherwise. To remove all rows and get a count pass "1" as the whereclause 37

38 delete Example public int deletecontact(contact contact) { // SQL Statement: DELETE FROM tblcontacts WHERE id =? SQLiteDatabase db = this.getwritabledatabase(); int result = db.delete( TABLE_CONTACTS, // table COL_KEY_ID + " =?", // whereclause new String[] { String.valueOf(contact.getId()) }); // whereargs } //-- close resources db.close(); return result; 38

39 Shared Preferances 39

40 SharedPreferences If you have a relatively small collection of key-values that you'd like to save, you should use the SharedPreferences API A SharedPreferences object points to a file containing key-value pairs and provides simple methods to read and write them Save and retrieve persistent key-value pairs of primitive data types boolean, float, int, long, string Each SharedPreferences file is managed by the framework and can be private or shared 40

41 Get SharedPreferences Object You can create a new shared preference file or access an existing one by calling one of two methods getsharedpreferences() - Use this if you need multiple shared preference files identified by name, which you specify with the first parameter getpreferences() - Use this from an Activity if you need to use only one shared preference file for the activity. Because this retrieves a default shared preference file that belongs to the activity, you don't need to supply a name 41

42 Get a SharedPreferences Object When naming your shared preference files, you should use a name that's uniquely identifiable to your app, such as com.mis49m.myapp.preference_file_key SharedPreferences sharedprefs = getsharedpreferences( getstring(r.string.preference_file_key), Context.MODE_PRIVATE); SharedPreferences sharedpref = getpreferences(context.mode_private); 42

43 Write to SharedPreferences Call edit() to get a SharedPreferences.Editor Add values with methods such as putboolean() and putstring() Commit the new values with commit() SharedPreferences sharedpref = getpreferences(context.mode_private); SharedPreferences.Editor editor = sharedpref.edit(); editor.putint("key", 1); editor.commit(); 43

44 Read from SharedPreferences Use SharedPreferences methods such as getboolean() getstring() SharedPreferences sharedpref = getpreferences(context.mode_private); long highscore = sharedpref.getint("key_high_score", 0); 44

45 Modes MODE_PRIVATE By setting this mode, the file can only be accessed using calling application MODE_WORLD_READABLE This mode allow other application to read the preferences MODE_WORLD_WRITEABLE This mode allow other application to write the preferences 45

SharedPreference. <map> <int name="access_count" value="3" /> </map>

SharedPreference. <map> <int name=access_count value=3 /> </map> 1 Android Data Storage Options Android provides several data storage options for you to save persistent application data depends on your specific needs: private/public, small/large datasets :- Internal

More information

Android: Data Storage

Android: Data Storage Android: Data Storage F. Mallet Frederic.Mallet@unice.fr Université Nice Sophia Antipolis Outline Data Storage Shared Preferences Internal Storage External Storage SQLite Databases Network Connection F.

More information

Mr. Pritesh N. Patel Assistant Professor MCA ISTAR, V. V. Nagar ANDROID DATABASE TUTORIAL

Mr. Pritesh N. Patel Assistant Professor MCA ISTAR, V. V. Nagar ANDROID DATABASE TUTORIAL Mr. Pritesh N. Patel Assistant Professor MCA ISTAR, V. V. Nagar ANDROID DATABASE TUTORIAL Mr. Pritesh N. Patel 1 Storage Options Android provides several options for you to save persistent application

More information

An Android Studio SQLite Database Tutorial

An Android Studio SQLite Database Tutorial An Android Studio SQLite Database Tutorial Previous Table of Contents Next An Android Studio TableLayout and TableRow Tutorial Understanding Android Content Providers in Android Studio Purchase the fully

More information

Database Development In Android Applications

Database Development In Android Applications ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Database Development In Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran

More information

SQLite. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 6: Working with Databases. What is a Database Server. Advantages of SQLite

SQLite. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 6: Working with Databases. What is a Database Server. Advantages of SQLite SQLite 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 6: Working with Databases Dr Dimitris C. Dracopoulos SQLite is a tiny yet powerful database engine. Besides Android, it can be found in: Apple iphone

More information

CSCU9YH: Development with Android

CSCU9YH: Development with Android : Development with Android Computing Science and Mathematics University of Stirling Data Storage and Exchange 1 Preferences: Data Storage Options a lightweight mechanism to store and retrieve keyvalue

More information

SQLite Database. References. Overview. Structured Databases

SQLite Database. References. Overview. Structured Databases SQLite Database References Android Developers Article https://developer.android.com/training/basics/data-storage/databases.html Android SQLite Package Reference https://developer.android.com/reference/android/database/sqlite/package-summary.html

More information

Eng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza. Data persistence

Eng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza. Data persistence Eng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza Data persistence Shared preferences A method to store primitive data in android as key-value pairs, these saved data will

More information

Mobile and Ubiquitous Computing: Android Programming (part 4)

Mobile and Ubiquitous Computing: Android Programming (part 4) Mobile and Ubiquitous Computing: Android Programming (part 4) Master studies, Winter 2015/2016 Dr Veljko Pejović Veljko.Pejovic@fri.uni-lj.si Examples from: Mobile and Ubiquitous Computing Jo Vermeulen,

More information

The Basis of Data. Steven R. Bagley

The Basis of Data. Steven R. Bagley The Basis of Data Steven R. Bagley So far How to create a UI View defined in XML Java-based Activity as the Controller Services Long running processes Intents used to send messages between things asynchronously

More information

How-to s and presentations. Be prepared to demo them in class. https://sites.google.com/site/androidhowto/presentati ons

How-to s and presentations. Be prepared to demo them in class. https://sites.google.com/site/androidhowto/presentati ons Upcoming Assignments Readings: Chapter 6 by today Lab 3 due today (complete survey) Lab 4 will be available Friday (due February 5) Friday Quiz in Blackboard 2:10-3pm (Furlough) Vertical Prototype due

More information

Mobile Computing Practice # 2d Android Applications Local DB

Mobile Computing Practice # 2d Android Applications Local DB Mobile Computing Practice # 2d Android Applications Local DB In this installment we will add persistent storage to the restaurants application. For that, we will create a database with a table for holding

More information

Single Application Persistent Data Storage. CS 282 Principles of Operating Systems II Systems Programming for Android

Single Application Persistent Data Storage. CS 282 Principles of Operating Systems II Systems Programming for Android Single Application Persistent Data Storage CS 282 Principles of Operating Systems II Systems Programming for Android Android offers several ways to store data Files SQLite database SharedPreferences Android

More information

MOBILE APPLICATIONS PROGRAMMING

MOBILE APPLICATIONS PROGRAMMING Data Storage 23.12.2015 MOBILE APPLICATIONS PROGRAMMING Krzysztof Pawłowski Polsko-Japońska Akademia Technik Komputerowych STORAGE OPTIONS Shared Preferences SQLite Database Internal Storage External Storage

More information

Mobile Programming Lecture 10. ContentProviders

Mobile Programming Lecture 10. ContentProviders Mobile Programming Lecture 10 ContentProviders Lecture 9 Review In creating a bound service, why would you choose to use a Messenger over extending Binder? What are the differences between using GPS provider

More information

Spring Lecture 5 Lecturer: Omid Jafarinezhad

Spring Lecture 5 Lecturer: Omid Jafarinezhad Mobile Programming Sharif University of Technology Spring 2016 - Lecture 5 Lecturer: Omid Jafarinezhad Storage Options Android provides several options for you to save persistent application data. The

More information

CS371m - Mobile Computing. Persistence - SQLite

CS371m - Mobile Computing. Persistence - SQLite CS371m - Mobile Computing Persistence - SQLite In case you have not taken 347: Data Management or worked with databases as part of a job, internship, or project: 2 Databases RDBMS relational data base

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 - recap Views and Layouts Events Basic application components Activities Intents 9/15/2014

More information

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210 SQL: Concepts Todd Bacastow IST 210: Organization of Data 2/17/2004 1 Design questions How many entities are there? What are the major entities? What are the attributes of each entity? Is there a unique

More information

Android Components. Android Smartphone Programming. Matthias Keil. University of Freiburg

Android Components. Android Smartphone Programming. Matthias Keil. University of Freiburg Android Components Android Smartphone Programming Matthias Keil Institute for Computer Science Faculty of Engineering 3. November 2014 Outline 1 Data Storage 2 Messages to the User 3 Background Work 4

More information

Unit 1 - Chapter 4,5

Unit 1 - Chapter 4,5 Unit 1 - Chapter 4,5 CREATE DATABASE DatabaseName; SHOW DATABASES; USE DatabaseName; DROP DATABASE DatabaseName; CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype,... columnn

More information

SQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

SQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) SQL language Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c) 2011-2016 SQL - Structured Query Language SQL is a computer language for communicating with DBSM Nonprocedural (declarative) language What

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 -recap Views and Layouts Events Basic application components Activities Intents BroadcastReceivers

More information

Android Components Android Smartphone Programming. Outline University of Freiburg. Data Storage Database University of Freiburg. Notizen.

Android Components Android Smartphone Programming. Outline University of Freiburg. Data Storage Database University of Freiburg. Notizen. Android Components Android Smartphone Programming Matthias Keil Institute for Computer Science Faculty of Engineering 4. November 2013 Outline 1 2 Messages to the User 3 Background Work 4 App Widgets 5

More information

Object-Oriented Databases Object-Relational Mappings and Frameworks. Alexandre de Spindler Department of Computer Science

Object-Oriented Databases Object-Relational Mappings and Frameworks. Alexandre de Spindler Department of Computer Science Object-Oriented Databases Object-Relational Mappings and Frameworks Challenges Development of software that runs on smart phones. Data needs to outlive program execution Use of sensors Integration with

More information

Android Programming Lecture 16 11/4/2011

Android Programming Lecture 16 11/4/2011 Android Programming Lecture 16 11/4/2011 New Assignment Discuss New Assignment for CityApp GetGPS Search Web Service Parse List Coordinates Questions from last class It does not appear that SQLite, in

More information

Data storage and exchange in Android

Data storage and exchange in Android Mobile App Development 1 Overview 2 3 SQLite Overview Implementation 4 Overview Methods to implement URI like SQL 5 Internal storage External storage Overview 1 Overview 2 3 SQLite Overview Implementation

More information

Managing Data. However, we'll be looking at two other forms of persistence today: (shared) preferences, and databases.

Managing Data. However, we'll be looking at two other forms of persistence today: (shared) preferences, and databases. Managing Data This week, we'll be looking at managing information. There are actually many ways to store information for later retrieval. In fact, feel free to take a look at the Android Developer pages:

More information

Mediensystemen mit Android

Mediensystemen mit Android LFE Medieninformatik i ik Prof. Dr. Heinrich i Hußmann (Dozent), Alexander De Luca, Gregor Broll, Max-Emanuel Maurer (supervisors) Praktikum Entwicklung von Mediensystemen mit Android Storing, Retrieving

More information

Lab # 4. Data Definition Language (DDL)

Lab # 4. Data Definition Language (DDL) Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Lab # 4 Data Definition Language (DDL) Eng. Haneen El-Masry November, 2014 2 Objective To be familiar with

More information

ASSIGNMENT NO 2. Objectives: To understand and demonstrate DDL statements on various SQL objects

ASSIGNMENT NO 2. Objectives: To understand and demonstrate DDL statements on various SQL objects ASSIGNMENT NO 2 Title: Design and Develop SQL DDL statements which demonstrate the use of SQL objects such as Table, View, Index, Sequence, Synonym Objectives: To understand and demonstrate DDL statements

More information

Chapter # 7 Introduction to Structured Query Language (SQL) Part I

Chapter # 7 Introduction to Structured Query Language (SQL) Part I Chapter # 7 Introduction to Structured Query Language (SQL) Part I Introduction to SQL SQL functions fit into two broad categories: Data definition language Data manipulation language Basic command set

More information

SQL Commands & Mongo DB New Syllabus

SQL Commands & Mongo DB New Syllabus Chapter 15 : Computer Science Class XI ( As per CBSE Board) SQL Commands & Mongo DB New Syllabus 2018-19 SQL SQL is an acronym of Structured Query Language.It is a standard language developed and used

More information

App Development for Smart Devices. Lec #5: Content Provider

App Development for Smart Devices. Lec #5: Content Provider App Development for Smart Devices CS 495/595 - Fall 2011 Lec #5: Content Provider Tamer Nadeem Dept. of Computer Science Some slides adapted from Jussi Pohjolainen and Bob Kinney Objective Data Storage

More information

Atmiya Institute of Technology & Science, Rajkot Department of MCA

Atmiya Institute of Technology & Science, Rajkot Department of MCA Atmiya Institute of Technology & Science, Rajkot Department of MCA Chapter 10 Application Preference (/data/data//shared_prefs/.xml) Private Preference (Data sharing

More information

Data storage overview SQLite databases

Data storage overview SQLite databases http://www.android.com/ Data storage overview SQLite databases Data storage overview Assets (assets) and Resources (res/raw) Private data installed with the application (read-only) Use the android.content.res.xxx

More information

CSC Web Programming. Introduction to SQL

CSC Web Programming. Introduction to SQL CSC 242 - Web Programming Introduction to SQL SQL Statements Data Definition Language CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE Data Query Language SELECT SQL statements end with

More information

Sqlite Update Failed With Error Code 19 Android

Sqlite Update Failed With Error Code 19 Android Sqlite Update Failed With Error Code 19 Android i'm wrote simple DataBaseHelper to use SQlite in android. after create class as : static final int DATABASE_VERSION = 1, private SQLiteDatabase mdatabase,

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 - recap Views and Layouts Events Basic application components Activities Intents 9/22/2017

More information

Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama

Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama The Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Database Lab Lab # 2 Data Definition Language (DDL) Eng. Alaa O Shama October, 2015 Objective To be familiar

More information

CS378 -Mobile Computing. Persistence

CS378 -Mobile Computing. Persistence CS378 -Mobile Computing Persistence Saving State We have already seen saving app state into a Bundle on orientation changes or when an app is killed to reclaim resources but may be recreated later 2 Storing

More information

Business Analytics. SQL PL SQL [Oracle 10 g] P r i n c e S e t h i w w w. x l m a c r o. w e b s. c o m

Business Analytics. SQL PL SQL [Oracle 10 g] P r i n c e S e t h i w w w. x l m a c r o. w e b s. c o m Business Analytics Let s Learn SQL-PL SQL (Oracle 10g) SQL PL SQL [Oracle 10 g] RDBMS, DDL, DML, DCL, Clause, Join, Function, Queries, Views, Constraints, Blocks, Cursors, Exception Handling, Trapping,

More information

EMBEDDED SYSTEMS PROGRAMMING SQLite

EMBEDDED SYSTEMS PROGRAMMING SQLite EMBEDDED SYSTEMS PROGRAMMING 2017-18 SQLite DATA STORAGE: ANDROID Shared Preferences Filesystem: internal storage Filesystem: external storage SQLite (Also available in ios and WP) Network (e.g., Google

More information

DB Creation with SQL DDL

DB Creation with SQL DDL DB Creation with SQL DDL Outline SQL Concepts Data Types Schema/Table/View Creation Transactions and Access Control Objectives of SQL Ideally, database language should allow user to: create the database

More information

Chapter 13 : Informatics Practices. Class XI ( As per CBSE Board) SQL Commands. New Syllabus Visit : python.mykvs.in for regular updates

Chapter 13 : Informatics Practices. Class XI ( As per CBSE Board) SQL Commands. New Syllabus Visit : python.mykvs.in for regular updates Chapter 13 : Informatics Practices Class XI ( As per CBSE Board) SQL Commands New Syllabus 2018-19 SQL SQL is an acronym of Structured Query Language.It is a standard language developed and used for accessing

More information

Android SQLite Essentials

Android SQLite Essentials Android SQLite Essentials Develop Android applications with one of the most widely used database engines, SQLite Sunny Kumar Aditya Vikash Kumar Karn BIRMINGHAM - MUMBAI Android SQLite Essentials Copyright

More information

CS371m - Mobile Computing. Persistence

CS371m - Mobile Computing. Persistence CS371m - Mobile Computing Persistence Storing Data Multiple options for storing data associated with apps Shared Preferences Internal Storage device memory External Storage SQLite Database Network Connection

More information

CS378 -Mobile Computing. Persistence -SQLite

CS378 -Mobile Computing. Persistence -SQLite CS378 -Mobile Computing Persistence -SQLite Databases RDBMS relational data base management system Relational databases introduced by E. F. Codd Turing Award Winner Relational Database data stored in tables

More information

Private Institute of Aga NETWORK DATABASE LECTURER NIYAZ M. SALIH

Private Institute of Aga NETWORK DATABASE LECTURER NIYAZ M. SALIH Private Institute of Aga 2018 NETWORK DATABASE LECTURER NIYAZ M. SALIH Data Definition Language (DDL): String data Types: Data Types CHAR(size) NCHAR(size) VARCHAR2(size) Description A fixed-length character

More information

Chapter-14 SQL COMMANDS

Chapter-14 SQL COMMANDS Chapter-14 SQL COMMANDS What is SQL? Structured Query Language and it helps to make practice on SQL commands which provides immediate results. SQL is Structured Query Language, which is a computer language

More information

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1 SQL Fundamentals Chapter 3 Class 03: SQL Fundamentals 1 Class 03: SQL Fundamentals 2 SQL SQL (Structured Query Language): A language that is used in relational databases to build and query tables. Earlier

More information

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas SQL SQL Functionality stands for Structured Query Language sometimes pronounced sequel a very-high-level (declarative) language user specifies what is wanted, not how to find it number of standards original

More information

SQL Data Definition and Data Manipulation Languages (DDL and DML)

SQL Data Definition and Data Manipulation Languages (DDL and DML) .. Cal Poly CPE/CSC 365: Introduction to Database Systems Alexander Dekhtyar.. SQL Data Definition and Data Manipulation Languages (DDL and DML) Note: This handout instroduces both the ANSI SQL synatax

More information

SharedPreferences Internal Storage External Storage SQLite databases

SharedPreferences Internal Storage External Storage SQLite databases SharedPreferences Internal Storage External Storage SQLite databases Use when you want to store small amounts of primitive data A persistent map that holds key-value pairs of simple data types Automatically

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

UNIT-IV (Relational Database Language, PL/SQL)

UNIT-IV (Relational Database Language, PL/SQL) UNIT-IV (Relational Database Language, PL/SQL) Section-A (2 Marks) Important questions 1. Define (i) Primary Key (ii) Foreign Key (iii) unique key. (i)primary key:a primary key can consist of one or more

More information

SAVING SIMPLE APPLICATION DATA

SAVING SIMPLE APPLICATION DATA 1 DATA PERSISTENCE OBJECTIVES In this chapter, you will learn how to persist data in your Android applications. Persisting data is an important topic in application development, as users typically expect

More information

Exact Numeric Data Types

Exact Numeric Data Types SQL Server Notes for FYP SQL data type is an attribute that specifies type of data of any object. Each column, variable and expression has related data type in SQL. You would use these data types while

More information

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language Information Systems Engineering SQL Structured Query Language DDL Data Definition (sub)language 1 SQL Standard Language for the Definition, Querying and Manipulation of Relational Databases on DBMSs Its

More information

Full file at

Full file at ch2 True/False Indicate whether the statement is true or false. 1. The SQL command to create a database table is an example of DML. 2. A user schema contains all database objects created by a user. 3.

More information

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables

INDEX. 1 Basic SQL Statements. 2 Restricting and Sorting Data. 3 Single Row Functions. 4 Displaying data from multiple tables INDEX Exercise No Title 1 Basic SQL Statements 2 Restricting and Sorting Data 3 Single Row Functions 4 Displaying data from multiple tables 5 Creating and Managing Tables 6 Including Constraints 7 Manipulating

More information

Android Programming Lecture 15 11/2/2011

Android Programming Lecture 15 11/2/2011 Android Programming Lecture 15 11/2/2011 City Web Service Documentation: http://206.219.96.5/webcatalog/ Need a web services client library: KSOAP2 Acts as our function calling proxy Allows us to generate

More information

Data Storage Methods in Android

Data Storage Methods in Android Data Storage Methods in Android Data Storage Applica4ons o5en need to use some type of data storage for persistent data. The Android framework offers different data storage op4ons: Shared preferences:

More information

MySQL Introduction. By Prof. B.A.Khivsara

MySQL Introduction. By Prof. B.A.Khivsara MySQL Introduction By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and not for commercial use. Outline Design

More information

Pagina 1 di 5 13.1.4. INSERT Syntax 13.1.4.1. INSERT... SELECT Syntax 13.1.4.2. INSERT DELAYED Syntax INSERT [LOW_PRIORITY DELAYED HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [(col_name,...)] VALUES ({expr

More information

DS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

DS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) DS 1300 - Introduction to SQL Part 1 Single-Table Queries By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Overview 1. SQL introduction & schema definitions 2. Basic single-table

More information

MyDatabaseHelper. public static final String TABLE_NAME = "tbl_bio";

MyDatabaseHelper. public static final String TABLE_NAME = tbl_bio; Page 1 of 5 MyDatabaseHelper import android.content.context; import android.database.sqlite.sqliteopenhelper; class MyDatabaseHelper extends SQLiteOpenHelper { private static final String DB_NAME = "friend_db";

More information

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 10/e Education, Inc. All Rights Reserved. Each class you create becomes a new type that can be used to declare variables and create objects. You can declare new classes as needed;

More information

CMP-3440 Database Systems

CMP-3440 Database Systems CMP-3440 Database Systems Relational DB Languages SQL Lecture 06 zain 1 Purpose and Importance Database Language: To create the database and relation structures. To perform various operations. To handle

More information

HOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL

HOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL HOW TO CREATE AND MAINTAIN DATABASES AND TABLES By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate

More information

Database Programming with PL/SQL

Database Programming with PL/SQL Database Programming with PL/SQL 3-2 Objectives This lesson covers the following objectives: Recognize the SQL statements that can be directly included in a PL/SQL executable block Construct and execute

More information

Initialising the Views (GameFragment) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III)

Initialising the Views (GameFragment) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III) Dr Dimitris C. Dracopoulos Making a Move (GameFragment) Dimitris C. Dracopoulos 1/22 Initialising

More information

Simple Quesries in SQL & Table Creation and Data Manipulation

Simple Quesries in SQL & Table Creation and Data Manipulation Simple Quesries in SQL & Table Creation and Data Manipulation Based on CBSE Curriculum Class -11 By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region Neha Tyagi, PGT CS II Shift Jaipur Introduction

More information

RDBMS-Day3. SQL Basic DDL statements DML statements Aggregate functions

RDBMS-Day3. SQL Basic DDL statements DML statements Aggregate functions RDBMS-Day3 SQL Basic DDL statements DML statements Aggregate functions SQL SQL is used to make a request to retrieve data from a Database. The DBMS processes the SQL request, retrieves the requested data

More information

G64DBS Database Systems. Lecture 7 SQL SELECT. The Data Dictionary. Data Dictionaries. Different Sections of SQL (DDL) Different Sections of SQL (DCL)

G64DBS Database Systems. Lecture 7 SQL SELECT. The Data Dictionary. Data Dictionaries. Different Sections of SQL (DDL) Different Sections of SQL (DCL) G64DBS Database Systems Lecture 7 SQL SELECT Tim Brailsford Different Sections of SQL (DDL) The Data Definition Language (DDL): CREATE TABLE - creates a new database table ALTER TABLE - alters (changes)

More information

1) Introduction to SQL

1) Introduction to SQL 1) Introduction to SQL a) Database language enables users to: i) Create the database and relation structure; ii) Perform insertion, modification and deletion of data from the relationship; and iii) Perform

More information

ASSIGNMENT NO Computer System with Open Source Operating System. 2. Mysql

ASSIGNMENT NO Computer System with Open Source Operating System. 2. Mysql ASSIGNMENT NO. 3 Title: Design at least 10 SQL queries for suitable database application using SQL DML statements: Insert, Select, Update, Delete with operators, functions, and set operator. Requirements:

More information

SQL Data Definition Language: Create and Change the Database Ray Lockwood

SQL Data Definition Language: Create and Change the Database Ray Lockwood Introductory SQL SQL Data Definition Language: Create and Change the Database Pg 1 SQL Data Definition Language: Create and Change the Database Ray Lockwood Points: DDL statements create and alter the

More information

MySQL Workshop. Scott D. Anderson

MySQL Workshop. Scott D. Anderson MySQL Workshop Scott D. Anderson Workshop Plan Part 1: Simple Queries Part 2: Creating a database: creating a table inserting, updating and deleting data handling NULL values datatypes Part 3: Joining

More information

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer,

Index. Bitmap Heap Scan, 156 Bitmap Index Scan, 156. Rahul Batra 2018 R. Batra, SQL Primer, A Access control, 165 granting privileges to users general syntax, GRANT, 170 multiple privileges, 171 PostgreSQL, 166 169 relational databases, 165 REVOKE command, 172 173 SQLite, 166 Aggregate functions

More information

REXX/SQL for VM. User s Guide. Software Product Research

REXX/SQL for VM. User s Guide. Software Product Research REXX/SQL for VM User s Guide Software Product Research REXX/SQL for VM Version 1 Copyright Software Product Research 2000 SQL/Monitoring Facility is a product name owned by Software Product Research All

More information

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014 The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014 MySQL Setup, using console Data types Overview Creating users, databases and tables SQL queries INSERT, SELECT, DELETE WHERE, ORDER

More information

Mysql Manual Order By Multiple Columns Example

Mysql Manual Order By Multiple Columns Example Mysql Manual Order By Multiple Columns Example If there is an ORDER BY clause and a different GROUP BY clause, or if the ORDER BY or GROUP BY contains columns from tables other than the first table. Multiple

More information

5. Single-row function

5. Single-row function 1. 2. Introduction Oracle 11g Oracle 11g Application Server Oracle database Relational and Object Relational Database Management system Oracle internet platform System Development Life cycle 3. Writing

More information

INTRODUCTION TO DATABASE

INTRODUCTION TO DATABASE 1 INTRODUCTION TO DATABASE DATA: Data is a collection of raw facts and figures and is represented in alphabets, digits and special characters format. It is not significant to a business. Data are atomic

More information

Overview of MySQL Structure and Syntax [2]

Overview of MySQL Structure and Syntax [2] PHP PHP MySQL Database Overview of MySQL Structure and Syntax [2] MySQL is a relational database system, which basically means that it can store bits of information in separate areas and link those areas

More information

In-app Billing Version 3

In-app Billing Version 3 13 In-app Billing Version 3 Bruno Oliveira Developer Relations, Android 13 In-app billing! 2 In-app billing! Implement ALL the billing! 2 In-app billing! DO NOT WANT 2 PREVIOUSLY IN IN-APP BILLING 3 Easy

More information

How to define a relational schema for a data base?

How to define a relational schema for a data base? How to define a relational schema for a data base? 1 Professors Students Lectures PersNr Name Level Room StudNr Name Semester Lecture Title 2125 Sokrates C4 226 24002 Xenokrates 18 Nr 2126 Russel C4 232

More information

Introduction to pysqlite

Introduction to pysqlite Introduction to pysqlite A crash course to accessing SQLite from within your Python programs. Based on pysqlite 2.0. SQLite basics SQLite is embedded, there is no server Each SQLite database is stored

More information

Data about data is database Select correct option: True False Partially True None of the Above

Data about data is database Select correct option: True False Partially True None of the Above Within a table, each primary key value. is a minimal super key is always the first field in each table must be numeric must be unique Foreign Key is A field in a table that matches a key field in another

More information

Adapters. Marco Ronchetti Università degli Studi di Trento

Adapters. Marco Ronchetti Università degli Studi di Trento 1 Adapters Marco Ronchetti Università degli Studi di Trento Adapter - AdapterView AdapterView: a view whose children are determined by an Adapter. Adapter: a bridge between an AdapterView and the underlying

More information

Short List of MySQL Commands

Short List of MySQL Commands Short List of MySQL Commands Conventions used here: MySQL key words are shown in CAPS User-specified names are in small letters Optional items are enclosed in square brackets [ ] Items in parentheses must

More information

SQream Connector Native C SQream Technologies Version 1.2.0

SQream Connector Native C SQream Technologies Version 1.2.0 SQream Connector Native C++ 1.2.0 SQream Technologies 2019-03-27 Version 1.2.0 Table of Contents The SQream Native C++ Connector - Overview................................................. 1 1. API Reference............................................................................

More information

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Basic SQL Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries

More information

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management Tenth Edition Chapter 7 Introduction to Structured Query Language (SQL) Objectives In this chapter, students will learn: The basic commands and

More information

Questions and Answers. A. A DataSource is the basic service for managing a set of JDBC drivers.

Questions and Answers. A. A DataSource is the basic service for managing a set of JDBC drivers. Q.1) What is, in terms of JDBC, a DataSource? A. A DataSource is the basic service for managing a set of JDBC drivers B. A DataSource is the Java representation of a physical data source C. A DataSource

More information

CS 193A. Activity state and preferences

CS 193A. Activity state and preferences CS 193A Activity state and preferences This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Activity instance

More information

Structured Query Language (SQL) lab syllabus 4 th science. SQL is used to communicate with a database. it is the standard language for relational

Structured Query Language (SQL) lab syllabus 4 th science. SQL is used to communicate with a database. it is the standard language for relational Structured Query Language (SQL) lab syllabus 4 th science Introduction : * what is sql? SQL is used to communicate with a database. it is the standard language for relational database management systems.

More information

Array. Prepared By - Rifat Shahriyar

Array. Prepared By - Rifat Shahriyar Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types

More information