I want to use the method ContentResolver.update(Uri uri, ContentValues values, String where, String[] selectionArgs)
I know how to use it, but I wonder what it does with the ContentValues. Does it overwrite ALL existing ContentValues, or does it only overwrite the given ContentValues?
So for example, these ContentValues exist:
A: abc
B: 123
C: 456
And the ContentValues in the update()
method contain this:
A: asdf
C: 789
Then will the new ContentValues be: (only overwrite given values)
A: asdf
B: 123
C: 789
Or will it be: (overwrite all values)
A: asdf
C: 789
This is my code:
contentResolver.update(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values, "_data=" + audioFilePath, null);
In which values
contains the ContentValues
that should be overwritten and audioFilePath
contains the path to the audiofile (which is the value of _data
).
The ContentResolver object parses out the URI's authority, and uses it to "resolve" the provider by comparing the authority to a system table of known providers. The ContentResolver can then dispatch the query arguments to the correct provider.
The ContentResolver. query() client method always returns a Cursor. This cursor contains the column specified by the query projection. The cursor object provides read access to rows and columns.
The ContentResolver object sends requests (like create, read, update, and delete) to the ContentProvider as a client.
A content provider can be used to manage access to a variety of data storage sources, including both structured data, such as a SQLite relational database, or unstructured data such as image files. For more information on the types of storage available on Android, see Storage options, as well as Designing data storage.
It will only overwrite the given ContentValues.
As per the documentation, all the ContentResolver.update() method does is call the update method of the ContentProvider that you've defined and identified by the URI you provide in the first argument.
So, to know exactly what's going on, you need to look at how you defined the update() method of the ContentProvider you are referencing. Take a look at the ContentProvider basics documentation. If you need help properly defining the update() method of your contentProvider, post your code here or ask a question specific to that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With