Delete row from table - Android

Hello,

I saw that if I save a new registry that they already existst, this registry don’t update automatically.
So, first i want to delete this row and then save the new registry.
In android… How I can delete a row from a table with a WHERE clause for example “myId”.

That’s that i want:

I have this table: TABLEX
This table have two columns: myId, name
In this table i have two rows:
a111, Phill
a222, Mark

I want to DELETE from TABLEX WHERE myId = a111.

Thanks.

Try this:

HashMap objectToDelete = new HashMap();
objectToDelete.put( "objectId", "a111" );
Backendless.Data.of( "TABLEX" ).remove( objectToDelete );

seems that not work… i get this error:

BackendlessException{ code: ‘Internal client exception’, message: ‘null’ }

That was a blocking (synchronous) call. If you invoke it on the main UI thread, you need to make sure to use the non-blocking asynchronous version of the API:
https://backendless.com/docs/android/doc.html#data_deleting_data_objects

I put this in my code… but android studio tells me that:
Class ‘Anonymous class derived from AsyncCallback’ must either be declared abstract or implement abstract method ‘handleresponse(T)’ in ‘AsyncCallback’.

My code:

HashMap objectToDelete = new HashMap();
objectToDelete.put("Id", iddevice);
Backendless.Persistence.of( "ANSWERS" ).remove( objectToDelete, new  AsyncCallback<Map>() {
    public void handleResponse( Long response )
    {
        // new Contact instance has been saved
    }

    public void handleFault( BackendlessFault fault )
    {
        // an error has occurred, the error code can be retrieved with fault.getCode()
    }
});

Change to this:

HashMap objectToDelete = new HashMap();
objectToDelete.put("Id", iddevice);
Backendless.Persistence.of( "ANSWERS" ).remove( objectToDelete, new AsyncCallback<Long>() {
public void handleResponse( Long response )
{
// new Contact instance has been saved
}
public void handleFault( BackendlessFault fault )
{
// an error has occurred, the error code can be retrieved with fault.getCode()
}
});

Now i can run my app… but it does not delete the row who has the iddevice in column “Id”…

What’s your app id?