Delete is used to delete one or more contacts or contact groups from a contact database. It deletes data from a specified database or from the default database if you do not specify a database. This method can be called both in synchronous and asynchronous mode.
The following is an example for using Delete:
Asynchronous
event_id = contacts_handle.call('Delete', {'Type': u'Contact', 'Data': {'IdList': [req_id]}}, callback=del_contact)
where, del_contact is a user defined callback function.
The following table summarizes the specification of Delete:
| Interface | IDataSource |
| Operation | Deletes an array of contacts/groups from the specified or default contacts database. |
| Response Model | Asynchronous and synchronous for Third Edition FP2 and Fifth Edition devices. Synchronous for Third Edition and Third Edition FP1 devices. |
| Pre-condition | IDataSource interface is loaded. Contact must exist in the contacts database. The IDs can be obtained from GetList. |
| Post-condition | Nil |
Input Parameters
The following table describes input parameter. The default contacts database is cntdb://c:contacts.cdb. The SIM card database is sim://global_adn. The contacts or contacts groups to be deleted must exist in the specified database. You must use GetList to retrieve the IDs of the entries you want to delete.
|
Output Parameters
The output is an object, which contains ErrorCode and an ErrorMessage if the operation fails.
|
Errors
The following table lists the errors and their values:
|
Error Messages
The following table lists the error messages and their description:
|
Example
The following sample code illustrates how to delete a contact:
import scriptext
import e32
# Using e32.Ao_lock() to make main function wait till callback is hit
lock = e32.Ao_lock()
# Callback function will be called when the requested service is complete
def del_contact(trans_id, event_id, input_params):
if event_id != scriptext.EventCompleted:
# Check the event status
print "Error in deleting the contact"
print "Error code is: " + str(input_params["ReturnValue"]["ErrorCode"])
if "ErrorMessage" in input_params["ReturnValue"]:
print "Error message:" + input_params["ReturnValue"]["ErrorMessage"]
else:
print "The contact is deleted"
lock.signal()
# Load contacts module
contacts_handle = scriptext.load("Service.Contact", "IDataSource")
list_contacts = contacts_handle.call('GetList', {'Type': u'Contact', 'Filter': {'SearchVal': u'Paulo'}})
for i in list_contacts:
req_id = i['id']
event_id = contacts_handle.call('Delete', {'Type': u'Contact', 'Data':{'IdList': [req_id]}}, callback=del_contact)
print "Waiting for the request to be processed!"
lock.wait()
print "Request complete!"
See About this document... for information on suggesting changes.