cursor cursor = db.rawquery ("SELECT name from * * * * where id=?", New string[]{"1"});
cursor cursor = db.query ("* * *", new string[]{"name"}, "Id=?", New string[]{"1"}, NULL, NULL, NULL);
The above is two queries and rawquery query statements, the main difference is that Rawquery is directly using the SQL statement query, that is, the first parameter string, within the string "?" "will be replaced by an array of subsequent string[], and the query function is an Android-encapsulated querying API: Its API documentation is as follows:
Public Cursor Query (string table, string[] columns, string selection, string[] Selectionargs, string groupBy, String Having, String-by-clause)
Query The given table, returning a Cursor over the result set.
Table
The table name to compile the query against.
Columns
A List of which columns to return. Passing NULL would return all columns, which are discouraged to prevent reading data from storage This isn ' t going to being use D.
selection
A Filter declaring which rows to return, formatted as a SQL WHERE clause (excluding the where itself). Passing NULL would return all rows for the given table.
Selectionargs
May include? s in selection, which'll be replaced by the values from Selectionargs, in order that they appear in The selection. The values would be bound as Strings.
GroupBy
A Filter declaring how to group rows, formatted as a SQL GROUP BY clause (excluding the group by itself). Passing null would cause the rows to is grouped.
having
A Filter Declare which row groups to include in the cursor, if row grouping are being used, formatted as an SQL have clause (excluding the having itself). Passing null would cause all row groups to be included, and was required when row grouping was not being used.
by
How to order the rows, formatted as a SQL ORDER BY clause (excluding the order by itself). Passing NULL would use the default sort order, which could be unordered.
Returns
? A Cursor object, which is positioned before the first entry. Note that Cursors is not synchronized, see the documentation for more details.
The latter query compared to the former, there is a benefit, the former rawquery you write SQL statements, it is possible to write a wrong or write a missing word spelling error when he will make a mistake, and the second is relatively small probability of error
Comparison of Android Rawquery and query