How to update row on a unique Column in Android

Hi im getting fault 1155 (Duplicate entry ) when i try updating column as per android doc , where contact id is same and unique

Contact contact = new Contact(); contact.setName( "Jack Daniels" ); contact.setAge( 147 ); contact.setId(0) contact.setPhone( "777-777-777" ); contact.setTitle( "Favorites" ); Backendless.Persistence.save( contact, new AsyncCallback<Contact>() { public void handleResponse( Contact savedContact ) { savedContact.setTitle( "Most favorite" ); savedContact.setPhone( "666-666-666" ); Backendless.Persistence.save( savedContact, new AsyncCallback<Contact>() { @Override public void handleResponse( Contact response ) { // Contact instance has been updated } @Override public void handleFault( BackendlessFault fault ) { // an error has occurred, the error code can be retrieved with fault.getCode() } } ); } @Override public void handleFault( BackendlessFault fault ) { // an error has occurred, the error code can be retrieved with fault.getCode() } });

Hi deepansh,

Please, provide us the listing of code your Contact class.

Regards Ilya

public class Contact
{
private String id;
private String name;
private int age;
private String phone;
private String title;

public String getId() {
return id;
}

public void setId( String id ) {
this.id = id;
}

public String getName() {
return name;
}

public void setName( String name ) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge( int age ) {
this.age = age;
}

public String getPhone() {
return phone;
}

public void setPhone( String phone ) {
this.phone = phone;
}

public String getTitle() {
return title;
}

public void setTitle( String title ) {
this.title = title;
}
}

We still can’t reproduce this problem.
Please, add logging in each callback to differentiate creating errors and updating errors.
Are you sure that when you have an error it is not error of creating new contact?

Well i already have contact saved for the same unique id. But when m trying to update its column title and number using the documentation provide, it gives me a fault with error code 1155.

As I understood, when you run code described above you had already saved contact object with property id = ‘0’, right?
And then you made this:

Contact contact = new Contact();

contact.setName( "Jack Daniels" );
contact.setAge( 147 );
contact.setId(0);
contact.setPhone( "777-777-777" );
contact.setTitle( "Favorites" );

Backendless.Persistence.save( contact, new AsyncCallback<Contact>() {
public void handleResponse( Contact savedContact ) {
	savedContact.setTitle( "Most favorite" );
	savedContact.setPhone( "666-666-666" );
	
	Backendless.Persistence.save( savedContact, new AsyncCallback<Contact>() {
		@Override public void handleResponse( Contact response ) {
			// Contact instance has been updated
		} @Override public void handleFault( BackendlessFault fault ) {
			// an error has occurred, the error code can be retrieved with
			fault.getCode()
		}
	} );
} @Override public void handleFault( BackendlessFault fault ) {
	// an error has occurred, the error code can be retrieved with
	fault.getCode()
}
});

If I am right you should not create a new instance of Contact but retrieve already existing object and then update it.

have same problem… is there any way to update particular row-data of a table ??

Iliy has given the answer on this question