- There are four main ways to persist data in Android: shared preferences, file systems, external storage, and SQLite databases.
- SQLite is the default database used in Android. It is a lightweight relational database embedded within Android applications.
- The SQLiteOpenHelper class manages database creation, version management, and handles opening connections to the database. It requires a database name to create the database.
- The SQLiteDatabase class contains methods for executing SQL statements like create, insert, update, delete, and query. It is used to perform operations on the SQLite database like inserting, updating, deleting, and retrieving data.
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. In this chapter we will discuss about developing application with SQLite.
This document provides an overview and tutorial for using SQLite database tools in Android application development. It discusses the SQLiteOpenHelper and SQLiteDatabase classes, which are used to create, open, and manage an app's database. It then demonstrates how to create a database manager class that extends SQLiteOpenHelper to define the database structure, and includes methods like addRow(), deleteRow(), and updateRow() to interact with the database. The goal is to build reusable database functionality that can be included in most Android apps.
This document discusses using SQLite databases in Android applications. SQLite is an embedded SQL database that does not require a separate server. It is included in the Android SDK and can be used to create and query database files. The document explains how to open a database, create tables, insert/update/delete rows using SQL queries, and retrieve data using cursors. Raw queries and simple queries can be used to perform retrieval queries on a single table. Transactions are used to commit or roll back changes to the database.
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...TAISEEREISA
SQLite is an embedded SQL database that is included within Android applications. It allows creating, querying, and modifying a database without a separate server process. Developers can open and query a SQLite database using methods like openDatabase(), rawQuery(), execSQL(), and insert()/update()/delete(). This allows storing and retrieving application data, even when the device is offline.
Mobile applications Development - Lecture 13
Local/Session Storage
WebSQL
IndexedDB
File System Access
This presentation has been developed in the context of the Mobile Applications Development course at the Computer Science Department of the University of L’Aquila (Italy).
http://www.di.univaq.it/malavolta
This document provides instructions for connecting an SQLite database to an Android application using Android Studio. It describes creating a database using SQLite Manager and placing it in the Android project's assets folder. It then explains creating a Connection class with paths to the database folder and file. The document outlines creating a DataDB class to connect to the Connection class and calling getNameDB in the MainActivity to retrieve the database name. It provides code snippets for the Connection and DataDB classes.
The document discusses using SQLite database in Android applications. It explains that SQLite is a lightweight database that can be used to store and retrieve data in Android apps. It provides steps to create a database, add and retrieve records, and use the SQLiteOpenHelper class. Methods like onCreate(), onUpgrade(), and onOpen() are called at different stages of the database lifecycle. The document also discusses updating, deleting, and implementing the database in an example Android application.
This document provides information on creating a 3-tier web application architecture in Eclipse using JSP. It discusses dividing classes into sub-tasks like views, services and database layers. It also covers creating packages, JSP pages, beans, getters/setters, and service layers. The service layer interacts with the database layer using JDBC to perform operations like registration. The presentation layer posts data to JSP pages, which then call the service layer.
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. In this chapter we will discuss about developing application with SQLite.
This document provides an overview and tutorial for using SQLite database tools in Android application development. It discusses the SQLiteOpenHelper and SQLiteDatabase classes, which are used to create, open, and manage an app's database. It then demonstrates how to create a database manager class that extends SQLiteOpenHelper to define the database structure, and includes methods like addRow(), deleteRow(), and updateRow() to interact with the database. The goal is to build reusable database functionality that can be included in most Android apps.
This document discusses using SQLite databases in Android applications. SQLite is an embedded SQL database that does not require a separate server. It is included in the Android SDK and can be used to create and query database files. The document explains how to open a database, create tables, insert/update/delete rows using SQL queries, and retrieve data using cursors. Raw queries and simple queries can be used to perform retrieval queries on a single table. Transactions are used to commit or roll back changes to the database.
Chapter 3.pptx Oracle SQL or local Android database setup SQL, SQL-Lite, codi...TAISEEREISA
SQLite is an embedded SQL database that is included within Android applications. It allows creating, querying, and modifying a database without a separate server process. Developers can open and query a SQLite database using methods like openDatabase(), rawQuery(), execSQL(), and insert()/update()/delete(). This allows storing and retrieving application data, even when the device is offline.
Mobile applications Development - Lecture 13
Local/Session Storage
WebSQL
IndexedDB
File System Access
This presentation has been developed in the context of the Mobile Applications Development course at the Computer Science Department of the University of L’Aquila (Italy).
http://www.di.univaq.it/malavolta
This document provides instructions for connecting an SQLite database to an Android application using Android Studio. It describes creating a database using SQLite Manager and placing it in the Android project's assets folder. It then explains creating a Connection class with paths to the database folder and file. The document outlines creating a DataDB class to connect to the Connection class and calling getNameDB in the MainActivity to retrieve the database name. It provides code snippets for the Connection and DataDB classes.
The document discusses using SQLite database in Android applications. It explains that SQLite is a lightweight database that can be used to store and retrieve data in Android apps. It provides steps to create a database, add and retrieve records, and use the SQLiteOpenHelper class. Methods like onCreate(), onUpgrade(), and onOpen() are called at different stages of the database lifecycle. The document also discusses updating, deleting, and implementing the database in an example Android application.
This document provides information on creating a 3-tier web application architecture in Eclipse using JSP. It discusses dividing classes into sub-tasks like views, services and database layers. It also covers creating packages, JSP pages, beans, getters/setters, and service layers. The service layer interacts with the database layer using JDBC to perform operations like registration. The presentation layer posts data to JSP pages, which then call the service layer.
Introduction
Web Storage
WebSQL
IndexedDB
File System Access
Final Considerations
This presentation has been developed in the context of the Mobile Applications Development course, DISIM, University of L'Aquila (Italy), Spring 2015.
http://www.ivanomalavolta.com
The document discusses object-oriented programming in Python. It defines key OOP concepts like classes, objects, and methods. It provides examples of defining classes and methods in Python. It also covers inheritance, polymorphism, and data abstraction in OOP. Database programming in Python is also discussed, including connecting to databases and performing CRUD operations using the Python DB API.
The document provides an overview of object-oriented programming concepts in Python including defining classes, inheritance, methods, and data structures. Some key points:
- Classes define user-created data types that bundle together data (attributes) and functions (methods) that work with that data. Objects are instances of classes.
- Methods are defined within classes and must have "self" as the first argument to access attributes. The __init__ method serves as a constructor.
- Inheritance allows subclasses to extend existing classes, redefining or calling parent methods.
- Python supports lists, tuples, dictionaries, sets and other data structures that can be used to store and organize data. Lists are mutable while tuples are immutable.
Introduction
Web Storage
WebSQL
IndexedDB
File System Access
Final Considerations
This presentation has been developed in the context of the Mobile Applications Development course, DISIM, University of L'Aquila (Italy), Spring 2014.
http://www.ivanomalavolta.com
This document provides an overview of different data storage options in Android including shared preferences, internal storage, external storage, SQLite databases, and network connections. It also includes examples and workshops for using each data storage type with key points on shared preferences, internal and external storage paths, SQLiteOpenHelper, CRUD operations, and displaying data in a ListView.
This document provides a summary of automation testing topics covered on day 7, including parameters, environment variables, data tables, and examples of how to use them in tests. Parameters discussed include test, action, random number, and data table parameters. Environment variables can be built-in, user-defined, or stored in an external XML file. Data tables allow running tests with different data multiple times and have global and local sheets. Methods are provided to work with data tables, parameters, and sheets.
Zybotech solutions, offers job oriented courses on mobile application development for freshers and professionals with placement assistance, interactive training sessions with live project exposure.
This document provides an overview of Android application development training on accessing and manipulating data using SQLite databases on Android. It covers topics like what SQLite is, creating and connecting to databases, setting database properties, creating tables, inserting, updating, and deleting records from the databases using ContentValues and SQLiteDatabase methods. Code examples are provided for each topic.
Room provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite. It handles concerns like caching relevant data to access when offline and syncing changes to a server. There are three major Room components: the Database class that holds the database connection, Entities that represent tables, and DAOs that contain methods for database access. Room simplifies tasks like defining schemas, inserting/updating/deleting data, and handling schema changes through migrations.
The document provides an overview of the Java Database Connectivity (JDBC) API. It describes key interfaces like Connection, Statement, and PreparedStatement that are used to connect to a database and execute SQL statements. It also covers ResultSet for accessing query results, and the use of transactions and savepoints for maintaining data integrity. Classes like DriverManager help establish the initial connection to access databases using JDBC.
SQLite is a lightweight database that can be used to persist data between sessions of an Android app. The SQLiteOpenHelper class manages database creation and upgrading, and provides methods like onCreate() and onUpgrade() to define how the database schema is set up. Queries can be performed on the database using the query() method of the SQLiteDatabase class to retrieve data as a Cursor object.
Based on the materials for this week, create your own unique Datab.docxJASS44
Based on the materials for this week, create your own unique Database table using MySQL.
The table should contain at least 6 columns (use different data type, as appropriate for your application).
The table should have a Primary Key and one other constraint of your choice.
You should populate the table with 5 records.
Then Query the table to display all columns for all records.
You should provide the SQL script and screen captures of you successfully running the script.
Respond to other students by supplying scripts that add additional records, modiify or query data from the tables. Demonstrate your modifications worked by providing the screen shots of your scripts successfully running.
Business-level strategies are intended to help an organization take advantage of opportunities in its environment to create value for stakeholders. Low-cost and differentiation strategies are the two primary approaches used by organizations to gain competitive advantage at the business level. Describe the two types of strategies. Using the example of a chain of women’s clothing stores, analyze how such an organization might employ each type of strategy. How would the organization design its structure under each type of business-level strategy? How would the culture of the organization differ under each type of business-level strategy?
Should be at least 300 words. Does not have to be in paper format this is only a post
Name: William Clements
Class: SDEV 300
Section: 6380
Date: 6/15/2016
Lab 7
Screen Shot:
1
Introduction to MySQL
Overview
This lab walks you through using MySQL. MySQL is a relational database that can be used as part of Web
and other applications. This lab serves as a primer for using MySQL and will serve as a foundation when
we discuss SQL injection attacks and possible mitigations.
Learning Outcomes:
At the completion of the lab you should be able to:
1. Connect to a MySQL database and show the tables within the Ubuntu virtual machine
2. Create MySQL tables containing popular data types and constraints
3. Insert, update and delete data from MySQL database tables
4. Create and execute SQL Select statements and simple joins on MySQL tables
Lab Submission Requirements:
After completing this lab, you will submit a word (or PDF) document that meets all of the requirements in
the description at the end of this document. In addition, your MySQL file should be submitted. You can
submit multiple files in a zip file.
Virtual Machine Account Information
Your Virtual Machine has been preconfigured with all of the software you will need for this class. The
default username and password are:
Username : umucsdev
Password: umuc$d8v
MySQL Username: sdev_owner
MySQL password: sdev300
MySQL database: sdev
Part 1 – Connect to a MySQL database and show the tables within the Ubuntu virtual machine
The Virtual Machine already has MySQL installed. A MySQL username has also been created alon ...
Asp .Net Database Connectivity Presentation.pptxsridharu1981
This document provides an overview of connecting databases in ASP.NET using ADO.NET. It defines what a database and SQL are, and explains that in ASP.NET there are two main approaches to connecting to databases - ADO.NET and ORM tools like Entity Framework. It then focuses on using ADO.NET, describing how to declare connection strings, establish a connection using SqlConnection, execute commands with SqlCommand, read returned data with SqlDataReader, and close the connection once complete.
James Johnson is the founder and president of the Inland Empire .NET User's Group. He is a three time Microsoft MVP in CAD and works as a software developer during the day and runs side projects at night. He gave a presentation on Entity Framework and code first development in .NET. He discussed Entity Framework concepts like POCO objects, the entity data model, and LINQ queries. He also covered code first development, scaffolding with MVC, and maintaining databases as the data model changes.
Entity Framework Database and Code FirstJames Johnson
James Johnson is the founder and president of the Inland Empire .NET User's Group. He is a three time Microsoft MVP in CAD and works as a software developer during the day and runs side projects at night. He gave a presentation on Entity Framework and code first development where he demonstrated how to scaffold controllers and views from classes to generate a basic web application with CRUD functionality and database access.
queue datastructure made easy and datastructure explained in java. visit http://technoexplore.blogspot.com and http://hotjobstuff.blogspot.com for some other important presentations.
The document discusses queue data structures. A queue is a linear data structure where additions are made at the end/tail and removals are made from the front/head, following a First-In First-Out (FIFO) approach. Common queue operations include add, remove, check if empty, check if full. A queue can be stored using either a static array or dynamic linked nodes. The key aspects are maintaining references to the head and tail of the queue.
Storing data is a basic and very common need in mobile apps. The Android application framework provides several storage options, one of which is SQLite databases.
In this tutorial you will see a simple Android database example. The example is based on the Android ListView Tutorial and the Android AsyncTask Tutorial, however these tutorials are not mandatory for the purpose of understanding the principles of proper Android database usage.
Android Training (Storing data using SQLite)Khaled Anaqwa
SQLite is an open-source database that is embedded into every Android device. It requires limited memory and supports standard SQL features. The document discusses how to use SQLite in Android applications by creating a SQLiteOpenHelper subclass to define database creation and updating methods. It also describes implementing a DAO interface to perform CRUD operations on the database and models.
Presented Research Paper entitled “Artificial Intelligence in Higher Education: A Literature Study and Proposed
Framework " International Conference on “Recent trends in Pure and Applied Science “ at RIT, Islampur on
24/03/2023
This document discusses Android broadcast receivers and intents. It defines broadcasts as system-wide events that occur from actions like receiving a phone call or the device charging. Broadcast receivers are used to respond to these broadcasts. There are two types of broadcast receivers: static, declared in the manifest, and dynamic, which only work when the app is active. The document provides examples of system-generated broadcasts and how to implement both context-registered and manifest-registered broadcast receivers in Android. It also explains intents, intent filters, and their components like actions and categories.
Introduction
Web Storage
WebSQL
IndexedDB
File System Access
Final Considerations
This presentation has been developed in the context of the Mobile Applications Development course, DISIM, University of L'Aquila (Italy), Spring 2015.
http://www.ivanomalavolta.com
The document discusses object-oriented programming in Python. It defines key OOP concepts like classes, objects, and methods. It provides examples of defining classes and methods in Python. It also covers inheritance, polymorphism, and data abstraction in OOP. Database programming in Python is also discussed, including connecting to databases and performing CRUD operations using the Python DB API.
The document provides an overview of object-oriented programming concepts in Python including defining classes, inheritance, methods, and data structures. Some key points:
- Classes define user-created data types that bundle together data (attributes) and functions (methods) that work with that data. Objects are instances of classes.
- Methods are defined within classes and must have "self" as the first argument to access attributes. The __init__ method serves as a constructor.
- Inheritance allows subclasses to extend existing classes, redefining or calling parent methods.
- Python supports lists, tuples, dictionaries, sets and other data structures that can be used to store and organize data. Lists are mutable while tuples are immutable.
Introduction
Web Storage
WebSQL
IndexedDB
File System Access
Final Considerations
This presentation has been developed in the context of the Mobile Applications Development course, DISIM, University of L'Aquila (Italy), Spring 2014.
http://www.ivanomalavolta.com
This document provides an overview of different data storage options in Android including shared preferences, internal storage, external storage, SQLite databases, and network connections. It also includes examples and workshops for using each data storage type with key points on shared preferences, internal and external storage paths, SQLiteOpenHelper, CRUD operations, and displaying data in a ListView.
This document provides a summary of automation testing topics covered on day 7, including parameters, environment variables, data tables, and examples of how to use them in tests. Parameters discussed include test, action, random number, and data table parameters. Environment variables can be built-in, user-defined, or stored in an external XML file. Data tables allow running tests with different data multiple times and have global and local sheets. Methods are provided to work with data tables, parameters, and sheets.
Zybotech solutions, offers job oriented courses on mobile application development for freshers and professionals with placement assistance, interactive training sessions with live project exposure.
This document provides an overview of Android application development training on accessing and manipulating data using SQLite databases on Android. It covers topics like what SQLite is, creating and connecting to databases, setting database properties, creating tables, inserting, updating, and deleting records from the databases using ContentValues and SQLiteDatabase methods. Code examples are provided for each topic.
Room provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite. It handles concerns like caching relevant data to access when offline and syncing changes to a server. There are three major Room components: the Database class that holds the database connection, Entities that represent tables, and DAOs that contain methods for database access. Room simplifies tasks like defining schemas, inserting/updating/deleting data, and handling schema changes through migrations.
The document provides an overview of the Java Database Connectivity (JDBC) API. It describes key interfaces like Connection, Statement, and PreparedStatement that are used to connect to a database and execute SQL statements. It also covers ResultSet for accessing query results, and the use of transactions and savepoints for maintaining data integrity. Classes like DriverManager help establish the initial connection to access databases using JDBC.
SQLite is a lightweight database that can be used to persist data between sessions of an Android app. The SQLiteOpenHelper class manages database creation and upgrading, and provides methods like onCreate() and onUpgrade() to define how the database schema is set up. Queries can be performed on the database using the query() method of the SQLiteDatabase class to retrieve data as a Cursor object.
Based on the materials for this week, create your own unique Datab.docxJASS44
Based on the materials for this week, create your own unique Database table using MySQL.
The table should contain at least 6 columns (use different data type, as appropriate for your application).
The table should have a Primary Key and one other constraint of your choice.
You should populate the table with 5 records.
Then Query the table to display all columns for all records.
You should provide the SQL script and screen captures of you successfully running the script.
Respond to other students by supplying scripts that add additional records, modiify or query data from the tables. Demonstrate your modifications worked by providing the screen shots of your scripts successfully running.
Business-level strategies are intended to help an organization take advantage of opportunities in its environment to create value for stakeholders. Low-cost and differentiation strategies are the two primary approaches used by organizations to gain competitive advantage at the business level. Describe the two types of strategies. Using the example of a chain of women’s clothing stores, analyze how such an organization might employ each type of strategy. How would the organization design its structure under each type of business-level strategy? How would the culture of the organization differ under each type of business-level strategy?
Should be at least 300 words. Does not have to be in paper format this is only a post
Name: William Clements
Class: SDEV 300
Section: 6380
Date: 6/15/2016
Lab 7
Screen Shot:
1
Introduction to MySQL
Overview
This lab walks you through using MySQL. MySQL is a relational database that can be used as part of Web
and other applications. This lab serves as a primer for using MySQL and will serve as a foundation when
we discuss SQL injection attacks and possible mitigations.
Learning Outcomes:
At the completion of the lab you should be able to:
1. Connect to a MySQL database and show the tables within the Ubuntu virtual machine
2. Create MySQL tables containing popular data types and constraints
3. Insert, update and delete data from MySQL database tables
4. Create and execute SQL Select statements and simple joins on MySQL tables
Lab Submission Requirements:
After completing this lab, you will submit a word (or PDF) document that meets all of the requirements in
the description at the end of this document. In addition, your MySQL file should be submitted. You can
submit multiple files in a zip file.
Virtual Machine Account Information
Your Virtual Machine has been preconfigured with all of the software you will need for this class. The
default username and password are:
Username : umucsdev
Password: umuc$d8v
MySQL Username: sdev_owner
MySQL password: sdev300
MySQL database: sdev
Part 1 – Connect to a MySQL database and show the tables within the Ubuntu virtual machine
The Virtual Machine already has MySQL installed. A MySQL username has also been created alon ...
Asp .Net Database Connectivity Presentation.pptxsridharu1981
This document provides an overview of connecting databases in ASP.NET using ADO.NET. It defines what a database and SQL are, and explains that in ASP.NET there are two main approaches to connecting to databases - ADO.NET and ORM tools like Entity Framework. It then focuses on using ADO.NET, describing how to declare connection strings, establish a connection using SqlConnection, execute commands with SqlCommand, read returned data with SqlDataReader, and close the connection once complete.
James Johnson is the founder and president of the Inland Empire .NET User's Group. He is a three time Microsoft MVP in CAD and works as a software developer during the day and runs side projects at night. He gave a presentation on Entity Framework and code first development in .NET. He discussed Entity Framework concepts like POCO objects, the entity data model, and LINQ queries. He also covered code first development, scaffolding with MVC, and maintaining databases as the data model changes.
Entity Framework Database and Code FirstJames Johnson
James Johnson is the founder and president of the Inland Empire .NET User's Group. He is a three time Microsoft MVP in CAD and works as a software developer during the day and runs side projects at night. He gave a presentation on Entity Framework and code first development where he demonstrated how to scaffold controllers and views from classes to generate a basic web application with CRUD functionality and database access.
queue datastructure made easy and datastructure explained in java. visit http://technoexplore.blogspot.com and http://hotjobstuff.blogspot.com for some other important presentations.
The document discusses queue data structures. A queue is a linear data structure where additions are made at the end/tail and removals are made from the front/head, following a First-In First-Out (FIFO) approach. Common queue operations include add, remove, check if empty, check if full. A queue can be stored using either a static array or dynamic linked nodes. The key aspects are maintaining references to the head and tail of the queue.
Storing data is a basic and very common need in mobile apps. The Android application framework provides several storage options, one of which is SQLite databases.
In this tutorial you will see a simple Android database example. The example is based on the Android ListView Tutorial and the Android AsyncTask Tutorial, however these tutorials are not mandatory for the purpose of understanding the principles of proper Android database usage.
Android Training (Storing data using SQLite)Khaled Anaqwa
SQLite is an open-source database that is embedded into every Android device. It requires limited memory and supports standard SQL features. The document discusses how to use SQLite in Android applications by creating a SQLiteOpenHelper subclass to define database creation and updating methods. It also describes implementing a DAO interface to perform CRUD operations on the database and models.
Presented Research Paper entitled “Artificial Intelligence in Higher Education: A Literature Study and Proposed
Framework " International Conference on “Recent trends in Pure and Applied Science “ at RIT, Islampur on
24/03/2023
This document discusses Android broadcast receivers and intents. It defines broadcasts as system-wide events that occur from actions like receiving a phone call or the device charging. Broadcast receivers are used to respond to these broadcasts. There are two types of broadcast receivers: static, declared in the manifest, and dynamic, which only work when the app is active. The document provides examples of system-generated broadcasts and how to implement both context-registered and manifest-registered broadcast receivers in Android. It also explains intents, intent filters, and their components like actions and categories.
A computer is an electronic device that can perform a variety of tasks by executing instructions. It is versatile and can handle tasks like documentation, accounting, designing, airlines/railways bookings, weather forecasting, and more. The central processing unit carries out the instructions of computer programs by performing basic arithmetic, logical, control and input/output operations. Other key parts include the monitor for visual display, mouse for pointing/selecting, keyboard for text input, printer for printing output, modem for connecting to networks, and speakers for audio output. Computers are characterized by their speed, accuracy, reliability, storage capacity, versatility, and ability to reduce manpower and paperwork.
The document discusses the seaborn visualization library in Python. It provides an introduction to seaborn and explains how to install and import it. It then covers various types of plots that can be created with seaborn, including relational plots (scatterplots, lineplots), categorical plots (barplots, countplots, boxplots, violinplots, stripplots, swarmplots, factorplots), regression plots (lmplots), and matrix plots (heatmaps, clustermaps). It provides code examples for creating each type of plot and using different parameters to visualize relationships between variables in datasets.
The document discusses classification algorithms. Classification algorithms are supervised learning techniques that categorize new observations into classes based on a training dataset. They map inputs (x) to discrete outputs (y) by finding a mapping function or decision boundary. Common classification algorithms include logistic regression, k-nearest neighbors, support vector machines, naive Bayes, decision trees, and random forests. Classification algorithms are used to solve problems involving categorizing data into discrete classes, such as identifying spam emails or cancer cells.
- There are four main ways to persist data in Android: shared preferences, file systems, external storage, and SQLite databases.
- SQLite is the default database used in Android. It is a lightweight relational database embedded within Android applications.
- The SQLiteOpenHelper class manages database creation, version management, and handles opening connections to the database. It requires a database name to create the database.
- The SQLiteDatabase class contains methods for executing SQL statements like insert, update, delete, and query to perform CRUD operations on the database.
Instagram has become one of the most popular social media platforms, allowing people to share photos, videos, and stories with their followers. Sometimes, though, you might want to view someone's story without them knowing.
Discover the benefits of outsourcing SEO to Indiadavidjhones387
"Discover the benefits of outsourcing SEO to India! From cost-effective services and expert professionals to round-the-clock work advantages, learn how your business can achieve digital success with Indian SEO solutions.
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfFlorence Consulting
Quattordicesimo Meetup di Milano, tenutosi a Milano il 23 Maggio 2024 dalle ore 17:00 alle ore 18:30 in presenza e da remoto.
Abbiamo parlato di come Axpo Italia S.p.A. ha ridotto il technical debt migrando le proprie APIs da Mule 3.9 a Mule 4.4 passando anche da on-premises a CloudHub 1.0.
1. Data Persistence in
Android
- PRESENTED BY –
MRS. N. G. MANDLIK
ASSISTANT PROFESSOR,
DEPARTMENT OF COMPUTER STUDIES,
CSIBER, KOLHAPUR
2. What is Data persistence?
► Persistence is “the continuance of an effect after its cause is removed.”
► In the context of storing data in a computer system, it means that the data survives
after the process with which it was created has ended.
► In other words, for a data store to be considered persistent, it must write to non-
volatile storage.
3. Why to persist data?
► Persisting data is important in application development, as users typically expect to
reuse data in the future.
► In Android, there are primarily four basic ways of persisting data-
► A lightweight mechanism known as shared preferences to save small chunks of data.
► Traditional file systems (Internal)
► External systems (Flash drive)
► A relational database management system through the support of SQLite databases.
5. Introducing SQLite
► SQLite is an light-weight, open-source relational database that is used to perform
database operations on android devices such as storing, manipulating or retrieving
persistent data from the database.
► By default, it is embedded in android. So to access this database, there is no need to
establish any connections for it like JDBC,ODBC etc.
► Android has the main package android.database.sqlite that contains the classes to
manage the databases.
► SQLite is considerably, the lighter version of SQL database. It supports standard
relations database features, like SQL syntax, transactions & SQL statements.
6. SQLite Packages and Classes
► Packages required for designing applications using SQLite are listed below:
► android.database
► android.database.sqlite
► android.content
► Classes required for designing applications using SQLite are listed below:
► android.database.sqlite.SQLiteOpenHelper
► android.database.sqlite.SQliteDatabase
► android.database.Cusor
► android.content.ContentValues
7. SQLiteOpenHelper
► SQLiteOpenHelper is a class found inside android.database.sqlite package.
► It is a helper class that helps in creating the database, handling the operations and
also the version management.
► For performing any database operation, you have to provide the implementation
of onCreate() and onUpgrade() methods of SQLiteOpenHelper class.
► To use SQLiteOpenHelper, create a class, and then extend SQLiteOpenHelper inside
the class that has been created.
► The SQLiteOpenHelper only require the DATABASE_NAME to create database.
8. ► Constructors of SQLiteOpenHelper class :
SQLiteOpenHelper
Constructor Description
SQLiteOpenHelper(Context context, String
name, SQLiteDatabase.CursorFactory factory, int
version)
creates an object for creating, opening and
managing the database.
SQLiteOpenHelper(Context context, String
name, SQLiteDatabase.CursorFactory factory, int
version, DatabaseErrorHandler errorHandler)
creates an object for creating, opening and
managing the database. It specifies the error
handler.
9. ► Methods of SQLiteOpenHelper class :
SQLiteOpenHelper
Method Description
public abstract void onCreate(SQLiteDatabase db) called only once when database is created for
the first time.
public abstract void onUpgrade(SQLiteDatabase
db, int oldVersion, int newVersion)
called when database needs to be upgraded.
public synchronized void close () closes the database object.
public void onDowngrade(SQLiteDatabase db, int
oldVersion, int newVersion)
called when database needs to be downgraded.
10. ► Important SQLiteOpenHelper Class Methods-
1. getWritableDatabase()
2. getReadableDatabase()
► Above methods return a reference to SQLiteDatabase as shown in the
following statement-
SQLiteDatabase db = this.getWritableDatabase();
SQLiteOpenHelper
11. SQLiteDatabase
► It is a class which contains methods to be performed on SQLite database
such as create, update, delete, select etc.
12. ► Methods of SQLiteDatabase class :
SQLiteDatabase
Method Description
void execSQL(String sql) executes the sql query not select query.
long insert(String table, String nullColumnHack,
ContentValues values)
inserts a record on the database. The table
specifies the table name, nullColumnHack
doesn't allow completely null values. If second
argument is null, android will store null values if
values are empty. The third argument specifies
the values to be stored.
int update(String table, ContentValues values,
String whereClause, String[ ] whereArgs)
updates a row. It returns the no. of values
affected.
Cursor query(String table, String[ ] columns, String
selection, String[ ] selectionArgs, String groupBy,
String having, String orderBy)
Creates a resultset and returns a cursor over it.
It enables the operations like- Filtering, Sorting,
Grouping, Grouping and Filtering on the data:
13. Creating a database
► Creating a database with the name “Library”-
public class DatabaseHandler extends SQLiteOpenHelper
{
public DatabaseHandler(Context c)
{
super(c, ”Library”, null, 1);
}
}
context object we will get it
from the activity while
creating the instance name of the database
If we want a cursor to be initialized on the
creation we can use cursor factory, it is optionall
and that is why we passed null
Database version
14. Creating a database
► Creating a “student” table in “Library” Database -
public void onCreate(SQLiteDatabase db)
{
db.execSQL(“CREATE TABLE student(rollno INTEGER PRIMARY
KEY,
name TEXT)”);
}
method of SQLiteDatabase class which accepts
the SQL query to be executed.
15. Performing database operations
1. Inserting a Record in a “student” table-
► Step-1 : Obtain a reference to SQLiteDatabase class object by invoking getWritableDatabase( )
method of Context class as-
SQLiteDatabase db = this.getWritableDatabase( );
► Step-2 : Create an object of ContentValues class by invoking a default constructor.
ContentValues c = new ContentValues( );
► Step-3 : Invoke put( ) method of ContentValues class which accepts two parameters, the first
parameter is a column name and the second parameter is a value.
c.put(“column_name”,”column_value”);
16. Performing database operations
1. Inserting a Record in a “student” table-
► Step-4 : Invoke insert() method of SQLiteDatabase class which accepts the following three
parameters:
► The first parameter is the String object specifying the name of the table in which the
record must be inserted.
► The second parameter is “null” which means “null” value should be stored in a column
if the value is empty.
► The third parameter is an instance of ContentValues class containing the values to be
inserted in different columns of a table.
17. Performing database operations
1. Inserting a Record in a “student” table-
► For Example-
SQLiteDatabase db = this.getWritableDatabase();
ContentValues c = new ContentValues();
c.put(“rollno‖”,1);
c.put(“name”, “xyz”);
db.insert(“student”, null, c);
db.close ();
18. Performing database operations
2. Updating a Record in a “student” table- Changing name of rollno 1 to ‘abc’
► Step-1 : Obtain a reference to SQLiteDatabase class object by invoking getWritableDatabase( )
method of Context class as-
SQLiteDatabase db = this.getWritableDatabase( );
► Step-2 : Create an object of ContentValues class by invoking a default constructor.
ContentValues c = new ContentValues( );
► Step-3 : Invoke put( ) method of ContentValues class which accepts two parameters, the first
parameter is a column name and the second parameter is a value.
c.put(“column_name”,”column_value”);
19. Performing database operations
2. Updating a Record in a “student” table- Changing name of rollno 1 to ‘abc’
► Step-4 : Invoke update() method of SQLiteDatabase class which accepts the following four
parameters:
► The first parameter is a String object specifying the name of the table to be updated.
► The second parameter is an instance of ContentValues class containing updated values.
► The third parameter is a condition containing ‘?‘ place holder for runtime parameters.
► The fourth parameter is a String array supplying values for place holders of argument 3.
20. Performing database operations
2. Updating a Record in a “student” table- Changing name of rollno 1 to ‘abc’
► For Example-
SQLiteDatabase db = this.getWritableDatabase();
ContentValues c = new ContentValues();
c.put(name,“abc");
db.update("student", c, "rollno = ?", new String [] {"1"});
db.close();
21. Performing database operations
3. Deleting a Record from a student table- Delete a Record with Rollno 2
► Step-1 : Obtain a reference to SQLiteDatabase class object by invoking getWritableDatabase( )
method of Context class as-
SQLiteDatabase db = this.getWritableDatabase( );
► Step-2 : Invoke delete() method of SQLiteDatabase class which accepts the following three
parameters:
►The first parameter is a String object specifying the name of the table from which the record
is deleted.
►The second parameter is a condition containing ‘?‘ place holder for runtime parameters.
►The third parameter is a String array supplying values for place holders of argument 2.
22. Performing database operations
3. Deleting a Record from a student table- Delete a Record with Rollno 2
► For Example-
SQLiteDatabase db = this.getWritableDatabase();
db.delete(“student”, “rollno = ?”, new String [] {“2”});
db.close();
23. Performing database operations
4. Retrieving all Records from a student table
Method 1: Using query() method of SQLiteDatabase Class - The main steps involved in creating a
cursor over a result set retrieved from a “student‟ table are-
► Step - 1 : Obtain a reference to SQLiteDatabase class object by invoking getWritableDatabase( )
method of Context class as-
SQLiteDatabase db = this.getWritableDatabase( );
► Step - 2 : Invoke query() method of SQLiteDatabase class which accepts the following seven
parameters:
►The first parameter is a String object specifying the name of the table.
►The second parameter is the array of string objects containing the column names.
►The third parameter is a filter string.
24. ► The fourth parameter is a String array containing filter parameters.
► The fifth parameter is a String object specifying the name of GroupBy column.
► The sixth parameter is ‘Having’ condition
► The seventh parameter is a String object specifying the sort column name.
SQLiteDatabase db = this.getWritableDatabase();
Cusor c = db.query(“student”, new
String[] {“rollno”, “name”}, null, null, null, null, null);
db.close();
25. Performing database operations
4. Retrieving all Records from a student table
Method 2: Using rawQuery() method of SQLiteDatabase Class - The main steps involved in
creating a cursor over a result set retrieved from a “student‟ table are-
► Step - 1 : Obtain a reference to SQLiteDatabase class object by invoking getWritableDatabase( )
method of Context class as-
SQLiteDatabase db = this.getWritableDatabase( );
► Step - 2 : Invoke rawQuery() method of SQLiteDatabase class which accepts the following two
parameters:
► The first parameter is a SELECT query which may contain a runtime parameter specified by ‘ ? ’.
► The second parameter is an array of String objects specifying runtime parameter value or null, if
runtime parameters are not present.
26. SQLiteDatabase db = this.getWritableDatabase ();
Cursor c= db.rawQuery(“SELECT * FROM student”, null);
db.close();
27. Navigating Through the Records of
a student table
► The Cursor class supports the following methods for navigating through the records of
result set.
Method Description
moveToFirst() Moves the pointer to the first record of result set.
moveToNext() Moves the pointer to the next record of result set.
getX() Retrieves the value of the column with the specified index
(index starts at 0) of the record at the current cursor position.
X is any valid column type.
28. ► For example,
SQLiteDatabase db = this.getWritableDatabase ();
Cursor c= db.rawQuery(“SELECT * FROM student”, null);
int rollno, String name;
StringBuffer sb=new StringBuffer();
if (c.moveToFirst()) {
do {
rollno = c.getInt(0);
name = c.getString(1);
sb.append(String.valueOf(rollno));
sb.append(“ “);
sb.append(name);
sb.append(“n”);
} while (c.moveToNext());
}
db.close();
30. What is Content Provider?
► Do you know how applications share data?
► All kinds of data sharing among the applications are available due to the content
provider.
► Content Providers act as a medium for various applications to communicate with each
other.
► The role of the content provider in the android system is like a central repository in which
data of the applications are stored, and it facilitates other applications to securely access and
modifies that data based on the user requirements.
► It manages and looks over the application data like images, audio, videos, and personal
contact information and accesses the SQLite Database.
31. What is Content Provider?
► In order to share the data, content providers have certain permissions that are used to grant
or restrict the rights to other applications to interfere with the data.
► All the seeking of data is done through the content provider itself. Whenever you require
access to data from other applications, the content provider seeks permission from the user
to access the data to the other application.
► For Example, Whenever any application needs to access some pictures from the gallery, it seeks
your permission, and the content provider provides you with the required content.
► Some of the examples of Content Providers in Android are-
► Music Playlist has a list of songs.
► Calls Logs contain the call details.
► Contact List that contain Contact details.
► Message Threads
► Gallery Application that contains images
► File Manager, etc
32. ► Content providers let you centralize content in
one place and have many different applications
access it as needed.
► A content provider behaves very much like a
database where you can query it, edit its
content, as well as add or delete content using
insert(), update(), delete(), and query()
methods.
► In most cases this data is stored in
an SQlite database.
33. Diagram - how the content provider helps in sharing data with applications
from data stores.
34. ► Four basic operations known as CRUD Operations provided by the
content provider are-
C – Create : It is used for the creation of data in content providers.
R – Read : It reads the data stored in the content provider.
U – Update : It lets the editing in existing data in content providers.
D – Delete : It deletes the existing data stored in its Storage.
35. Working of Content Provider in Android
(Accessing Data with Content Provider)
► We need to establish a connection using the “ContentResolver”
object to get the data from the content provider.
► The ContentResolver object helps the application to communicate
with the Content Provider.
► In the next step, we need to connect ContentResolver object with the
user interface.
► We require another object called “CursorLoader” so the user can
interact directly with the Content Provider by using the user
interface.
► The CursorLoader receives the user’s query request and forward it to
the Content Provider.
► The content Provider executes the query and provides the requested
data to the user .
36. Methods of Content Provider
It receives a request from the client. By using arguments it will get a data from
the requested table and return the data as a Cursor object.
To insert a new row in the database of the content provider. It returns the
content URI of the inserted row.
This method will update existing rows in content provider and returns the
number of rows updated.
This method will delete the rows in content provider and returns the number of
rows deleted.
It returns the Multipurpose Internet Mail Extension type of data to the given
Content URI.
As the content provider is created, the android system calls this method
immediately to initialise the provider.
37. Content URIs in Android
► Content URI(Uniform Resource Identifier) is the key concept of Content providers
which identifies the data in the content providers.
► To access the data from a content provider, URI is used as a query string.
► Based on the Content URI, we get the required data.
► The structure of any Content URI can be divided into four types:
<prefix>://<authority>/<path>/<optional_id>
38. Content URIs in Android
► Details of different parts of Content URI:
► Prefix - Mandatory part of the URI as it represents that the given URI is a Content URI. Usually,
the prefix is set to content://.
► Authority – It is the unique name of the content provider, like photos, contacts for in-built
content providers. Generally Authority is the name of the package in which ContentProvider is
registered. For example, com.example.contentproviderdemo.MycontentProvider
► Path – It contains the location of the data. It is mostly used to identify individual tables. For
example, for retrieving the contacts from the “Contacts‟ content provider, the path would be
people and the format of URI is,
content://contacts/people
► ID – This is an optional parameter that is used to access specific records. For example, in the
case of “Contacts‟ content provider, for retrieving the contact no. 1, the format of the URI is,
content://contacts/people/1
39. Implementing Content Provider in Android
► A content provider is implemented as a subclass of ContentProvider class and must
implement a standard set of APIs that enable other applications to perform
transactions.
► A typical declaration of content provider is shown below:
public class MyContentProvider extends ContentProvider {
}