Reputation: 356
I have been studying Content Providers by reading Android Developer Fundamentals (Version 1).
Under section "11.1 Share Data Through Content Providers" / "The query() method" there is a note that states
Note: The insert, delete, and update methods are provided for convenience and clarity. Technically, the query method could handle all requests, including those to insert, delete, and update data.
How can query method be used to insert / delete / and update data? The query method has the following signature and does not take in custom SQL strings.
public Cursor query(Uri uri, String[] projection, String selection,String[] selectionArgs, String sortOrder){}
I have not been able to find any resources that shows how this can be done. All seems to utilize the provided methods.
Upvotes: 0
Views: 367
Reputation: 1006849
Frankly, that is a really poor job in that training guide. All it will do is confuse people.
I presume what they mean is that there is nothing magic about query()
that forces it to only perform SQL SELECT
statements. A ContentProvider
is a facade — you can use it to store and retrieve from pretty much whatever you want, not just SQLite.
So, you could have your query()
method:
Uri
content://your.authority/something/insert/put/data/here
Uri
to get the put
, data
, and here
valuesMatrixCursor
Or, it could:
Uri
content://your.authority/something/insert
projection
for the columns and the selectionArgs
as the values to put in those columnsMatrixCursor
I do not know why anyone would do that, but it is certainly possible.
Upvotes: 1