I have a tables User and City, and I have one-to-one relationship
User can choose only existing city
how to make relationship between existed data from Android
like from console, where you can Press the “+” button and choose related data, as shown in Your example in console
Have you already read this page from documentation?
https://backendless.com/documentation/data/android/data_relations_save_update.htm
Yes, but there we always have to create new object.
if I have table “city” with defined fields, and I don’t want to add new fileds to this table
You should retrieve your user’s object with relations (to save them after all too) and the City object you want to link to user. Then just update relation property of User with City object (necessary for City object to have its objectId property) and save your User object.
In order to create a relation between a User and an existing city, you need to do the following:
- Retrieve the user object
Use the following API to create the relation between the User and the City: https://backendless.com/docs/android/doc.html#data_set_relation_with_condition_android
I looked at this documentation
but i can’t use “setRelation” or “addRelation”
If I understand correct, I must update Backendless to 4 version
Yes, you should update to version 4 of the SDK and make sure you are working with the 4.0 backend.
Thanks for reply