Update property

i wanna know how can i update the user property. i mean below is the code if i use it then it creates one more row in backendless (so now i user has 2 rows)

UserInformation userInformation = new UserInformation() ;
userInformation.setFullTimeStatus(“1”);

Backendless.Persistence.save( userInformation, new AsyncCallback<UserInformation>() {
public void handleResponse( UserInformation savedContact )
{

Toast.makeText(E_AccountSetup_FullTime_CodeNumber.this, “ENTRY uPDATED”, Toast.LENGTH_SHORT).show();

}
@Override
public void handleFault( BackendlessFault fault )
{

Toast.makeText(E_AccountSetup_FullTime_CodeNumber.this, "eNTRY UPDATED FAILED "+fault.getMessage(), Toast.LENGTH_SHORT).show();
// an error has occurred, the error code can be retrieved with fault.getCode()
}
});

i want to update the fullTimeStatus property to 1 i.e when user push a button.
but instead it creates a whole new row with the fullTimeStatus property as 1. i mean it is updating the property but it creates a new row.

Hello @Saad_Zahoor1

Try
UserInformation updatedUserInformation = Backendless.Persistence.of( UserInformation.class ).save( userInformation );

See more info - https://backendless.com/docs/android/data_single_object_update.html

Thank you for your time but i keep getting the new row. Instead of updating the the property on a given row i get new row with the property updated

Hi Saad
make sure that your userInformation has objectId property, because if it hasn’t a new one record will be created
regards, Vlad

I do this code:

UserInformation userInformation = new UserInformation( “0” );
UserInformation savedUserInformation = Backendless.Data.of( UserInformation.class ).save( userInformation );

savedUserInformation.setFullTimeStatus( “1” );
UserInformation updatedUserInformation = Backendless.Persistence.of( UserInformation.class ).save( savedUserInformation );

Then i see to table - one object

yes i do have that property in the row

You must use objectId in updated object

I really appreciate if you give me a hint how can i update the property using row’s objectId

You try this?

UserInformation userInformation = new UserInformation( “0” );
UserInformation savedUserInformation = Backendless.Data.of( UserInformation.class ).save( userInformation );

savedUserInformation.setFullTimeStatus( “1” );
UserInformation updatedUserInformation = Backendless.Persistence.of( UserInformation.class ).save( savedUserInformation );

got error at this point new UserInformation( “0” ); what this one represent …

I do not know What you UserInformation class
For example:

{
  private String fullTimeStatus;

  public UserInformation()
  {
  }

  public UserInformation( String fullTimeStatus )
  {
    this.fullTimeStatus = fullTimeStatus;
  }

  public String getFullTimeStatus()
  {
    return fullTimeStatus;
  }

  public void setFullTimeStatus( String fullTimeStatus )
  {
    this.fullTimeStatus = fullTimeStatus;
  }
}

In your example, you immediately create a new object:

UserInformation userInformation = new UserInformation() ;

But you need to get the object in order to update it. For example:

UserInformation userInformation = Backendless.Data.of( UserInformation.class ).findById( <objectId> )

See more information - https://backendless.com/docs/android/data_basic_search.html
And only after that you can update it.

userInformation.setFullTimeStatus( “1” );
UserInformation updatedUserInformation = Backendless.Persistence.of( UserInformation.class ).save( userInformation );

If i want to update property in my Users class which holds the email passowrd of user i simply go with this code and it works fine

user.setProperty( “isVerified”, 2 );
Backendless.UserService.update( user, new AsyncCallback<BackendlessUser>()
{
public void handleResponse( BackendlessUser user )
{
// user has been updated

}

public void handleFault( BackendlessFault fault )
{
// user update failed, to get the error code call fault.getCode()
}
});

is not there is any way to update the property simply . i mean the documentation method also generate new row

This code:

UserInformation userInformation = Backendless.Data.of( UserInformation.class ).findById( <objectId> );
userInformation.setFullTimeStatus( “1” );
UserInformation updatedUserInformation = Backendless.Persistence.of( UserInformation.class ).save( userInformation );

is not there is any way to update the property simply . i mean the documentation method also generate new row

?