Query()
As one might expect, the method is where your content provider gets details on a query some activity wants to perform. It is up to you to actually process said query.
The query method gets the following as parameters:
• A representing the collection or instance being queried
• A representing the list of properties that should be returned
• A representing what amounts to a SQL clause, constraining which instances should be considered for the query results
• A representing values to “pour into” the clause, replacing any found there
• A representing what amounts to a SQL clause
You are responsible for interpreting these parameters however they make sense and returning a that can be used to iterate over and access the data.
As you can imagine, these parameters are aimed toward people using a SQLite database for storage. You are welcome to ignore some of these parameters (e.g., you can elect not to try to roll your own SQL ‑clause parser), but you need to document that fact so activities attempt to query you only by instance Uri and not using parameters you elect not to handle.
For SQLite‑backed storage providers, however, the method implementation should be largely boilerplate. Use a to convert the various parameters into a single SQL statement, then use on the builder to actually invoke the query and give you a back. The is what your method then returns.
For example, here is from :
Дата добавления: 2015-05-16; просмотров: 684;