Making Queries
Given a base , you can run a query to return data out of the content provider related to that . This has much of the feel of SQL: you specify the “columns” to return, the constraints to determine which “rows” to return, a sort order, etc. The difference is that this request is being made of a content provider, not directly of some database (e.g., SQLite).
The nexus of this is the method available to your activity. This method takes five parameters:
1. The base of the content provider to query, or the instance of a specific object to query
2. An array of properties of instances from that content provider that you want returned by the query
3. A constraint statement, functioning like a SQL clause
4. An optional set of parameters to bind into the constraint clause, replacing any ?s that appear there
5. An optional sort statement, functioning like a SQL clause
This method returns a object, which you can use to retrieve the data returned by the query.
“Properties” is to content providers as columns are to databases. In other words, each instance (row) returned by a query consists of a set of properties (columns), each representing some piece of data.
This will hopefully make more sense given an example.
Our content provider examples come from the sample application, specifically the class:
Дата добавления: 2015-05-16; просмотров: 669;