The document discusses SQLiteOpenHelper class and how it helps in performing database operations like creating, opening and upgrading a SQLite database. It also describes how to open a database using getWritableDatabase() or getReadableDatabase() methods, insert data into tables using ContentValues and insert() method, implement content providers to allow external access to the database and methods like query(), insert(), update() etc to perform database operations through content providers.
• Access and edit the semantic graph database via REST-Services
• Specify what can be seen and how it is displayed and edited via view configurations
• Make use of pre-defined resources
• Compose the back-end part for your own web-frontends
1.1 For each of the HTTP methods,GET,POST, andPUT, identifythe corresponding method in the HttpServletclass.
1.3 For each of the following operations, identify the interfaceand method name that should be used:
Retrieve HTML form parameters from the request
Retrieve a servlet initialization parameter
Retrieve HTTP request header information
Set an HTTP response header
set the content type of the response
Acquire a text stream for the response
Acquire a binary stream for the response
Redirect an HTTP request to another URL
1.4 Identify the interface and method to access values and resources and to set object attributes within the following three web scopes:
Request
Session
Context
1.5 Given a life-cycle method: init,service , or destroy, identify correct statements bout its purpose or about how and when it is invoked.
1.6 Use a RequestDispatcher to include or forward to a web resource.
1.1 For each of the HTTP methods,GET,POST, andPUT, identifythe corresponding method in the HttpServletclass.
1.3 For each of the following operations, identify the interfaceand method name that should be used:
Retrieve HTML form parameters from the request
Retrieve a servlet initialization parameter
Retrieve HTTP request header information
Set an HTTP response header
set the content type of the response
Acquire a text stream for the response
Acquire a binary stream for the response
Redirect an HTTP request to another URL
1.4 Identify the interface and method to access values and resources and to set object attributes within the following three web scopes:
Request
Session
Context
1.5 Given a life-cycle method: init,service , or destroy, identify correct statements bout its purpose or about how and when it is invoked.
1.6 Use a RequestDispatcher to include or forward to a web resource.
• Access and edit the semantic graph database via REST-Services
• Specify what can be seen and how it is displayed and edited via view configurations
• Make use of pre-defined resources
• Compose the back-end part for your own web-frontends
1.1 For each of the HTTP methods,GET,POST, andPUT, identifythe corresponding method in the HttpServletclass.
1.3 For each of the following operations, identify the interfaceand method name that should be used:
Retrieve HTML form parameters from the request
Retrieve a servlet initialization parameter
Retrieve HTTP request header information
Set an HTTP response header
set the content type of the response
Acquire a text stream for the response
Acquire a binary stream for the response
Redirect an HTTP request to another URL
1.4 Identify the interface and method to access values and resources and to set object attributes within the following three web scopes:
Request
Session
Context
1.5 Given a life-cycle method: init,service , or destroy, identify correct statements bout its purpose or about how and when it is invoked.
1.6 Use a RequestDispatcher to include or forward to a web resource.
1.1 For each of the HTTP methods,GET,POST, andPUT, identifythe corresponding method in the HttpServletclass.
1.3 For each of the following operations, identify the interfaceand method name that should be used:
Retrieve HTML form parameters from the request
Retrieve a servlet initialization parameter
Retrieve HTTP request header information
Set an HTTP response header
set the content type of the response
Acquire a text stream for the response
Acquire a binary stream for the response
Redirect an HTTP request to another URL
1.4 Identify the interface and method to access values and resources and to set object attributes within the following three web scopes:
Request
Session
Context
1.5 Given a life-cycle method: init,service , or destroy, identify correct statements bout its purpose or about how and when it is invoked.
1.6 Use a RequestDispatcher to include or forward to a web resource.
Spring Data is a high level SpringSource project whose purpose is to unify and ease the access to different kinds of persistence stores, both relational database systems and NoSQL data stores.
J2EE : Java servlet and its types, environmentjoearunraja2
The server-side extensions are nothing but the technologies that are used to create dynamic Web pages. Actually, to provide the facility of dynamic Web pages, Web pages need a container or Web server. To meet this requirement, independent Web server providers offer some proprietary solutions in the form of APIs (Application Programming Interface).
These APIs allow us to build programs that can run with a Web server. In this case, Java Servlet is also one of the component APIs of Java Platform Enterprise Edition (nowadays known as – ‘Jakarta EE’) which sets standards for creating dynamic Web applications in Java.
Today we all are aware of the need to create dynamic web pages i.e. the ones that can change the site contents according to the time or can generate the content according to the request received by the client. If you like coding in Java, then you will be happy to know that using Java there also exists a way to generate dynamic web pages and that way is Java Servlet. But before we move forward with our topic let’s first understand the need for server-side extensions.
Servlets are the Java programs that run on the Java-enabled web server or application server. They are used to handle the request obtained from the web server, process the request, produce the response, and then send a response back to the web server. Servlet is faster than CGI as it doesn’t involve the creation of a new process for every new request received.
Servlets, as written in Java, are platform independent.
Removes the overhead of creating a new process for each request as Servlet doesn’t run in a separate process. There is only a single instance that handles all requests concurrently. This also saves the memory and allows a Servlet to easily manage the client state.
It is a server-side component, so Servlet inherits the security provided by the Web server.
The API designed for Java Servlet automatically acquires the advantages of the Java platforms such as platform-independent and portability. In addition, it obviously can use the wide range of APIs created on Java platforms such as JDBC to access the database.
Many Web servers that are suitable for personal use or low-traffic websites are offered for free or at extremely cheap costs eg. Java servlet. However, the majority of commercial-grade Web servers are rather expensive, with the notable exception of Apache, which is free.
The Servlet Container
Servlet container, also known as Servlet engine, is an integrated set of objects that provide a run time environment for Java Servlet components. In simple words, it is a system that manages Java Servlet components on top of the Web server to handle the Web client requests.
Services provided by the Servlet container:
Network Services: Loads a Servlet class. The loading may be from a local file system, a remote file system or other network services. The Servlet container provides the network services over which the request and response are sent.
Data Transfer between Activities & DatabasesMuhammad Sajid
Data Transfer between Activities & Databases, Content Provider:
Content Provider will act as a central repository to store the data of the application in one place and make that data available for different applications to access whenever it’s required.
the Content Provider is a part of an android application and it will act as more like the relational database to store the app data. We can perform multiple operations like insert, update, delete and edit on the data stored in the content provider using insert(), update(), delete(), and query() methods.
Slides to understand and present Advanced .net topics with c# language. Topics like delegates, Indexer, Reflection API, Attributes, Collections in c#, File and I/O manipulation etc. are described with examples too.
Products and Categories
Let's think about what information we need, both to display to our customers and for the use of the store administrator.
Customers
Name of the product
Detailed description
Price
Photograph
Weight and the cost of shipping
Number of items in stock
categories
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
Spring Data is a high level SpringSource project whose purpose is to unify and ease the access to different kinds of persistence stores, both relational database systems and NoSQL data stores.
J2EE : Java servlet and its types, environmentjoearunraja2
The server-side extensions are nothing but the technologies that are used to create dynamic Web pages. Actually, to provide the facility of dynamic Web pages, Web pages need a container or Web server. To meet this requirement, independent Web server providers offer some proprietary solutions in the form of APIs (Application Programming Interface).
These APIs allow us to build programs that can run with a Web server. In this case, Java Servlet is also one of the component APIs of Java Platform Enterprise Edition (nowadays known as – ‘Jakarta EE’) which sets standards for creating dynamic Web applications in Java.
Today we all are aware of the need to create dynamic web pages i.e. the ones that can change the site contents according to the time or can generate the content according to the request received by the client. If you like coding in Java, then you will be happy to know that using Java there also exists a way to generate dynamic web pages and that way is Java Servlet. But before we move forward with our topic let’s first understand the need for server-side extensions.
Servlets are the Java programs that run on the Java-enabled web server or application server. They are used to handle the request obtained from the web server, process the request, produce the response, and then send a response back to the web server. Servlet is faster than CGI as it doesn’t involve the creation of a new process for every new request received.
Servlets, as written in Java, are platform independent.
Removes the overhead of creating a new process for each request as Servlet doesn’t run in a separate process. There is only a single instance that handles all requests concurrently. This also saves the memory and allows a Servlet to easily manage the client state.
It is a server-side component, so Servlet inherits the security provided by the Web server.
The API designed for Java Servlet automatically acquires the advantages of the Java platforms such as platform-independent and portability. In addition, it obviously can use the wide range of APIs created on Java platforms such as JDBC to access the database.
Many Web servers that are suitable for personal use or low-traffic websites are offered for free or at extremely cheap costs eg. Java servlet. However, the majority of commercial-grade Web servers are rather expensive, with the notable exception of Apache, which is free.
The Servlet Container
Servlet container, also known as Servlet engine, is an integrated set of objects that provide a run time environment for Java Servlet components. In simple words, it is a system that manages Java Servlet components on top of the Web server to handle the Web client requests.
Services provided by the Servlet container:
Network Services: Loads a Servlet class. The loading may be from a local file system, a remote file system or other network services. The Servlet container provides the network services over which the request and response are sent.
Data Transfer between Activities & DatabasesMuhammad Sajid
Data Transfer between Activities & Databases, Content Provider:
Content Provider will act as a central repository to store the data of the application in one place and make that data available for different applications to access whenever it’s required.
the Content Provider is a part of an android application and it will act as more like the relational database to store the app data. We can perform multiple operations like insert, update, delete and edit on the data stored in the content provider using insert(), update(), delete(), and query() methods.
Slides to understand and present Advanced .net topics with c# language. Topics like delegates, Indexer, Reflection API, Attributes, Collections in c#, File and I/O manipulation etc. are described with examples too.
Products and Categories
Let's think about what information we need, both to display to our customers and for the use of the store administrator.
Customers
Name of the product
Detailed description
Price
Photograph
Weight and the cost of shipping
Number of items in stock
categories
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
The Metaverse and AI: how can decision-makers harness the Metaverse for their...Jen Stirrup
The Metaverse is popularized in science fiction, and now it is becoming closer to being a part of our daily lives through the use of social media and shopping companies. How can businesses survive in a world where Artificial Intelligence is becoming the present as well as the future of technology, and how does the Metaverse fit into business strategy when futurist ideas are developing into reality at accelerated rates? How do we do this when our data isn't up to scratch? How can we move towards success with our data so we are set up for the Metaverse when it arrives?
How can you help your company evolve, adapt, and succeed using Artificial Intelligence and the Metaverse to stay ahead of the competition? What are the potential issues, complications, and benefits that these technologies could bring to us and our organizations? In this session, Jen Stirrup will explain how to start thinking about these technologies as an organisation.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™UiPathCommunity
In questo evento online gratuito, organizzato dalla Community Italiana di UiPath, potrai esplorare le nuove funzionalità di Autopilot, il tool che integra l'Intelligenza Artificiale nei processi di sviluppo e utilizzo delle Automazioni.
📕 Vedremo insieme alcuni esempi dell'utilizzo di Autopilot in diversi tool della Suite UiPath:
Autopilot per Studio Web
Autopilot per Studio
Autopilot per Apps
Clipboard AI
GenAI applicata alla Document Understanding
👨🏫👨💻 Speakers:
Stefano Negro, UiPath MVPx3, RPA Tech Lead @ BSP Consultant
Flavio Martinelli, UiPath MVP 2023, Technical Account Manager @UiPath
Andrei Tasca, RPA Solutions Team Lead @NTT Data
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
2. SQLiteOpenHelper Class
• Is one of the abstract classes that allows a user to access a
database in READ mode or WRITE mode.
• Helps in performing the manipulation of data available in
the Db.
• Operation includes creating, opening and upgrading.
• Uses methods like getWritableDatabase() to write ,
getReadableDatabase() to read, close() to close the
database by running the object of SQLite database.
• insert() method inserting no. of rows in database table,
query() method executing various SQLite queries.
3. How a database is opened
• Can be accessed getWritableDatabase or
getReadableDatabase of SQLiteOpenHelper
class.
• onCreate handler is triggered if the searched
database doesn’t exists.
• Sometimes getWritableDatabase might not
work for reasons like permission, disk space.
In such case we can use getReadableDatabase
method.
• Sample in next slide
4. Code
• DBOpenHelper hp = new DBOpenHelper(e,
DBOpenHelper.name, null, DBOpenHelper.v);
• SQLiteDatabase db;
• try
• {
• db = DBOpenHelper.getWritableDatabase();
• }
• catch (SQLiteException e)
• {
• db = DBOpenHelper.getReadableDatabase();
• }
5. Method to insert data into table
• New row in database can be created using ContentValues
object (add column name and value)
• insert() used for inserting data into table.
• Accepts 3 arguments namely table name, null column hack
and name value pairs.
• The argument table indicates name of the table,
• null column hack prevents an error when inserting a new
record without specifying field value pairs and
• name value pairs are the actual data that need to be
inserted in a table.
• db.insert(DBOpenHelper.DATABASE_NAME, null, values);
6. Content Provider
• Content providers let you centralize content 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.
• 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.
7. Content URIs
• To query a content provider, you specify the query string in the form
of a URI which has following format −
• <prefix>://<authority>/<data_type>/<id>
Sr.No Part & Description
1
prefix
This is always set to content://
2
authority
This specifies the name of the content provider, for
example contacts, browser etc. For third-party content providers, this could be
the fully qualified name, such as com.mrecw.statusprovider
3
data_type
This indicates the type of data that this particular provider provides. For
example, if you are getting all the contacts from the Contacts content provider,
then the data path would be people and URI would look like
thiscontent://contacts/people
4
id
This specifies the specific record requested. For example, if you are looking
for contact number 5 in the Contacts content provider then URI would look
like this content://contacts/people/5.
8. How content provider is registered.
• The content provider need to be registered in the app manifest.
A provider tag is used for this purpose.
• This tag accompanies name attribute that represents providers
class name and authorities tag.
• The latter tag is used to define the base URI of providers
authority.
• Authority of a content provider is used by content
resolver in form of address to find the required data.
• com.<CompanyName>.provider.<AppliocationName>
• The provider tag is below with XML format
• <provider android :name=“.MyContentProvider”
android:authorities =“com.paad.skeletondbprovider”/>
9. Create Content Provider
• This involves number of simple steps to create your own content
provider.
• First of all you need to create a Content Provider class that extends
the ContentProviderbaseclass.
• Second, you need to define your content provider URI address which
will be used to access the content.
• Third you will need to create your own database to keep the content.
• Usually, Android uses SQLite database and framework needs to
override onCreate() method which will use SQLite Open Helper method
to create or open the provider's database.
• When your application is launched, the onCreate() handler of each of its
Content Providers is called on the main application thread.
• Fourth you will have to implement Content Provider queries to perform
different database specific operations.
• Finally register your Content Provider in your activity file using
<provider> tag.
10. List of methods which you need to override in Content
Provider class to have your Content Provider working −
• onCreate() This method is called when the provider is
started.
• query() This method receives a request from a client.
The result is returned as a Cursor object.
• insert()This method inserts a new record into the
content provider.
• delete() This method deletes an existing record from
the content provider.
• update() This method updates an existing record from
the content provider.
• getType() This method returns the MIME type of the
data at the given URI
11. Implementing the Content Provider query() Method
• When a content provider is called upon to return data, the query() method of
the provider class will be called.
• When called, this method is passed some or all of the following arguments:
• URI – The URI specifying the data source on which the query is to be
performed. This can take the form of a general query with multiple results, or
a specific query targeting the ID of a single table row.
• Projection – A row within a database table can comprise multiple columns of
data. In the case of this application,
• for example, these correspond to the ID, product name and product
quantity. The projection argument is simply a String array containing the name
for each of the columns that is to be returned in the result data set.
• Selection – The “where” element of the selection to be performed as part of
the query. This argument controls which rows are selected from the specified
database.
• For example, if the query was required to select only products named “Cat
Food” then the selection string passed to the query() method would read
productname = “Cat Food”.
• Selection Args – Any additional arguments that need to be passed to the SQL
query operation to perform the selection.
• ‘Sort Order' – The sort order for the selected rows.
12. • When called, the query() method is required to
perform the following operations:
• Use the sUriMatcher to identify the Uri type.
• Throw an exception if the URI is not valid.
• Construct a SQL query based on the criteria passed to
the method. For convenience, the SQLiteQueryBuilder
class can be used in construction of the query.
• Execute the query operation on the database.
• Notify the content resolver of the operation.
• Return a Cursor object containing the results of the
query.
14. insert()
• This method now needs to be modified to perform the
following tasks:
• Use the UriMatcher to identify the URI type.
• Throw an exception if the URI is not valid.
• Obtain a reference to a writable instance of the
underlying SQLite database.
• Perform a SQL insert operation to insert the data into
the database table.
• Notify the corresponding content resolver that the
database has been modified.
• Return the URI of the newly added table row.
15. Inserting content into content provider
• When a client application or activity requests that data be
inserted into the underlying database, the insert() method
of the content provider class will be called.
• At this point, however, all that exists in the
ContentProvider.java file of the project is a stub method,
which reads as follows:
• @Override public Uri insert(Uri arg0, ContentValues arg1) {
• // TODO Auto-generated method stub return null;
• }
16. • @Override
• public Uri insert(Uri uri, ContentValues values) {
• int uriType = sURIMatcher.match(uri);
• SQLiteDatabase sqlDB = myDB.getWritableDatabase();
• long id = 0;
• switch (uriType) {
• case PRODUCTS:
• id = sqlDB.insert(MyDBHandler.TABLE_PRODUCTS, null, values);
• break;
• default:
• throw new IllegalArgumentException("Unknown URI: " + uri);
• }
• getContext().getContentResolver().notifyChange(uri, null);
• return Uri.parse(PRODUCTS_TABLE + "/" + id);
• }
17. Implementing the Content Provider update() Method
• The update() method of the content provider is called
when changes are being requested to existing database
table rows. The method is passed a URI, the new values
in the form of a ContentValues object and the usual
selection argument strings.
• When called, the update() method would typically
perform the following steps:
• Use the sUriMatcher to identify the URI type.
• Throw an exception if the URI is not valid.
• Obtain a reference to a writable instance of the
underlying SQLite database.
• Notify the content resolver of the database change.
• Return a count of the number of rows that were changed
as a result of the update operation.