Skip to main content
The following example shows how to set a foreign key to a Contact and how to retrieve a Contact using its foreign key.

Code

Walk-through

In this example, we set a foreignkey of the contact with ID 2. We have retrieved a ForignAppRow by passing the Appname. If such a row does not exist in the foreignapp table, a new row will be created. After setting the application device you know the ID of the foreign device that you wish to associate your keys with. A key always associates with a foreign device; hence it is important to know the foreign device ID. You can set a foreign key to a Contact with the help of RowForeignKeyHelper. All the changes are added to the database when the RowforeignKeyHelper is saved. You can retrieve its foreignkey value via the contact. For that, you need to know the foreign device ID and the foreignKey. In the latter part of this example, we have retrieved a contact using custom search and the foreignkey is used as a restriction.