// get the ContentResolver ContentResolver resolver = getContentResolver(); // query the content provider for a list of contacts Cursor cursor = resolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); // iterate over the results while(cursor.moveToNext()) { // do something with each contact }
// get the ContentResolver ContentResolver resolver = getContentResolver(); // insert a new record into the content provider Uri newRecordUri = resolver.insert(MyContentProvider.CONTENT_URI, values); // update an existing record in the content provider int rowsUpdated = resolver.update(MyContentProvider.CONTENT_URI, values, selection, selectionArgs); // delete a record from the content provider int rowsDeleted = resolver.delete(MyContentProvider.CONTENT_URI, selection, selectionArgs);In this example, we use getContentResolver to get the ContentResolver object and then use it to interact with a custom content provider called "MyContentProvider". We insert a new record into the content provider, update an existing record, and delete a record.